From ab93a250013ad01620992581923583cbf93ed3db Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Thu, 13 Sep 2018 18:42:32 +0200 Subject: Rustfmt --- validator_derive/tests/complex.rs | 64 ++++++++++----------------------------- 1 file changed, 16 insertions(+), 48 deletions(-) (limited to 'validator_derive/tests/complex.rs') diff --git a/validator_derive/tests/complex.rs b/validator_derive/tests/complex.rs index 0df26c0..7826a49 100644 --- a/validator_derive/tests/complex.rs +++ b/validator_derive/tests/complex.rs @@ -3,15 +3,14 @@ extern crate validator_derive; extern crate validator; #[macro_use] extern crate serde_derive; -extern crate serde_json; extern crate regex; +extern crate serde_json; #[macro_use] extern crate lazy_static; use regex::Regex; -use validator::{Validate, ValidationError, ValidationErrors, ValidationErrorsKind}; use std::collections::HashMap; - +use validator::{Validate, ValidationError, ValidationErrors, ValidationErrorsKind}; fn validate_unique_username(username: &str) -> Result<(), ValidationError> { if username == "xXxShad0wxXx" { @@ -46,13 +45,13 @@ struct SignupData { #[validate] card: Option, #[validate] - preferences: Vec + preferences: Vec, } #[derive(Debug, Validate, Deserialize)] struct Phone { #[validate(phone)] - number: String + number: String, } #[derive(Debug, Validate, Deserialize)] @@ -77,19 +76,9 @@ fn is_fine_with_many_valid_validations() { site: "http://hello.com".to_string(), first_name: "Bob".to_string(), age: 18, - phone: Phone { - number: "+14152370800".to_string() - }, - card: Some(Card { - number: "5236313877109142".to_string(), - cvv: 123 - }), - preferences: vec![ - Preference { - name: "marketing".to_string(), - value: false - }, - ] + phone: Phone { number: "+14152370800".to_string() }, + card: Some(Card { number: "5236313877109142".to_string(), cvv: 123 }), + preferences: vec![Preference { name: "marketing".to_string(), value: false }], }; assert!(signup.validate().is_ok()); @@ -102,19 +91,9 @@ fn failed_validation_points_to_original_field_name() { site: "http://hello.com".to_string(), first_name: "".to_string(), age: 18, - phone: Phone { - number: "123 invalid".to_string(), - }, - card: Some(Card { - number: "1234567890123456".to_string(), - cvv: 1 - }), - preferences: vec![ - Preference { - name: "abc".to_string(), - value: true - }, - ] + phone: Phone { number: "123 invalid".to_string() }, + card: Some(Card { number: "1234567890123456".to_string(), cvv: 1 }), + preferences: vec![Preference { name: "abc".to_string(), value: true }], }; let res = signup.validate(); // println!("{}", serde_json::to_string(&res).unwrap()); @@ -286,9 +265,7 @@ fn test_works_with_question_mark_operator() { site: "http://hello.com".to_string(), first_name: "Bob".to_string(), age: 18, - phone: Phone { - number: "+14152370800".to_string() - }, + phone: Phone { number: "+14152370800".to_string() }, card: None, preferences: Vec::new(), }; @@ -314,27 +291,18 @@ fn test_works_with_none_values() { range: Option, } - let p = PutStruct { - name: None, - address: None, - age: None, - range: None, - }; + let p = PutStruct { name: None, address: None, age: None, range: None }; - let q = PutStruct { - name: None, - address: Some(None), - age: Some(None), - range: None, - }; + let q = PutStruct { name: None, address: Some(None), age: Some(None), range: None }; assert!(p.validate().is_ok()); assert!(q.validate().is_ok()); } fn unwrap_map(errors: &Box, f: F) - where F: FnOnce(HashMap<&'static str, ValidationErrorsKind>) +where + F: FnOnce(HashMap<&'static str, ValidationErrorsKind>), { let errors = *errors.clone(); f(errors.errors()); -} \ No newline at end of file +} -- cgit v1.2.3