aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vdovin2017-09-28 16:04:24 +0200
committerDmitry Vdovin2017-09-28 16:06:58 +0200
commitc644dc0aba4e927d299b0f93fd3b87bbaf8f366c (patch)
tree1ddeb8b7bccc25b5263fb21b20f0d2a9b5d191a3
parente9e22536bca048216c3c57196a4c2c1352b30e68 (diff)
downloadvalidator-c644dc0aba4e927d299b0f93fd3b87bbaf8f366c.tar.bz2
[#29] Add test for `?` operator
-rw-r--r--validator_derive/tests/complex.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/validator_derive/tests/complex.rs b/validator_derive/tests/complex.rs
index db5f1bf..0bd74fa 100644
--- a/validator_derive/tests/complex.rs
+++ b/validator_derive/tests/complex.rs
@@ -9,7 +9,7 @@ extern crate regex;
extern crate lazy_static;
use regex::Regex;
-use validator::{Validate, ValidationError};
+use validator::{Validate, ValidationError, ValidationErrors};
fn validate_unique_username(username: &str) -> Result<(), ValidationError> {
@@ -153,3 +153,20 @@ fn test_can_validate_option_fields_without_lifetime() {
};
assert!(s.validate().is_ok());
}
+
+#[test]
+fn test_works_with_question_mark_operator() {
+ fn some_fn() -> Result<(), ValidationErrors> {
+ let signup = SignupData {
+ mail: "invalid_email".to_string(),
+ site: "http://hello.com".to_string(),
+ first_name: "Bob".to_string(),
+ age: 18,
+ };
+
+ signup.validate()?;
+ Ok(())
+ }
+
+ assert!(some_fn().is_err());
+}