aboutsummaryrefslogtreecommitdiffstats
path: root/validator_derive/tests/compile-fail
diff options
context:
space:
mode:
authorVincent Prouillet2016-12-29 13:13:42 +0900
committerVincent Prouillet2016-12-29 13:16:41 +0900
commita0f2b4c0d4820bfdcc13c7abdfdc7802d9f6d493 (patch)
tree75b5bc7b008ac374ac0a437de580d5eda1c67a52 /validator_derive/tests/compile-fail
parentce9ee1ce4ac73ba7989c88c67b16243cbcec2b98 (diff)
downloadvalidator-a0f2b4c0d4820bfdcc13c7abdfdc7802d9f6d493.tar.bz2
Added must_match
Diffstat (limited to 'validator_derive/tests/compile-fail')
-rw-r--r--validator_derive/tests/compile-fail/must_match/field_doesnt_exist.rs15
-rw-r--r--validator_derive/tests/compile-fail/must_match/field_type_doesnt_match.rs16
2 files changed, 31 insertions, 0 deletions
diff --git a/validator_derive/tests/compile-fail/must_match/field_doesnt_exist.rs b/validator_derive/tests/compile-fail/must_match/field_doesnt_exist.rs
new file mode 100644
index 0000000..03828e2
--- /dev/null
+++ b/validator_derive/tests/compile-fail/must_match/field_doesnt_exist.rs
@@ -0,0 +1,15 @@
+#![feature(proc_macro, attr_literals)]
+
+#[macro_use] extern crate validator_derive;
+extern crate validator;
+use validator::Validate;
+
+#[derive(Validate)]
+//~^ ERROR: custom derive attribute panicked
+//~^^ HELP: Invalid attribute #[validate] on field `password`: invalid argument for `must_match` validator: field doesn't exist in struct
+struct Test {
+ #[validate(must_match = "password2")]
+ password: String,
+}
+
+fn main() {}
diff --git a/validator_derive/tests/compile-fail/must_match/field_type_doesnt_match.rs b/validator_derive/tests/compile-fail/must_match/field_type_doesnt_match.rs
new file mode 100644
index 0000000..61c0847
--- /dev/null
+++ b/validator_derive/tests/compile-fail/must_match/field_type_doesnt_match.rs
@@ -0,0 +1,16 @@
+#![feature(proc_macro, attr_literals)]
+
+#[macro_use] extern crate validator_derive;
+extern crate validator;
+use validator::Validate;
+
+#[derive(Validate)]
+//~^ ERROR: custom derive attribute panicked
+//~^^ HELP: Invalid attribute #[validate] on field `password`: invalid argument for `must_match` validator: types of field can't match
+struct Test {
+ #[validate(must_match = "password2")]
+ password: String,
+ password2: i32,
+}
+
+fn main() {}