aboutsummaryrefslogtreecommitdiffstats
path: root/validator_derive/tests/compile-fail/range
diff options
context:
space:
mode:
authorVincent Prouillet2016-12-27 14:31:17 +0900
committerVincent Prouillet2016-12-28 11:49:43 +0900
commitc5c76fac8726d53988092d71c818d38f12e8348e (patch)
treefffc8d3c5f369da2b935d118a2118d2fcca905a5 /validator_derive/tests/compile-fail/range
downloadvalidator-c5c76fac8726d53988092d71c818d38f12e8348e.tar.bz2
Initial commit
Diffstat (limited to 'validator_derive/tests/compile-fail/range')
-rw-r--r--validator_derive/tests/compile-fail/range/missing_arg.rs15
-rw-r--r--validator_derive/tests/compile-fail/range/no_args.rs15
-rw-r--r--validator_derive/tests/compile-fail/range/unknown_arg.rs15
-rw-r--r--validator_derive/tests/compile-fail/range/wrong_arg_type.rs15
-rw-r--r--validator_derive/tests/compile-fail/range/wrong_type.rs15
5 files changed, 75 insertions, 0 deletions
diff --git a/validator_derive/tests/compile-fail/range/missing_arg.rs b/validator_derive/tests/compile-fail/range/missing_arg.rs
new file mode 100644
index 0000000..94913cf
--- /dev/null
+++ b/validator_derive/tests/compile-fail/range/missing_arg.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 `s`: Validator `range` requires 2 arguments: `min` and `max`
+struct Test {
+ #[validate(range(min = 2.0))]
+ s: i32,
+}
+
+fn main() {}
diff --git a/validator_derive/tests/compile-fail/range/no_args.rs b/validator_derive/tests/compile-fail/range/no_args.rs
new file mode 100644
index 0000000..0532cc0
--- /dev/null
+++ b/validator_derive/tests/compile-fail/range/no_args.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 `s`: Validator `range` requires 2 arguments: `min` and `max`
+struct Test {
+ #[validate(range())]
+ s: i32,
+}
+
+fn main() {}
diff --git a/validator_derive/tests/compile-fail/range/unknown_arg.rs b/validator_derive/tests/compile-fail/range/unknown_arg.rs
new file mode 100644
index 0000000..7d2ac57
--- /dev/null
+++ b/validator_derive/tests/compile-fail/range/unknown_arg.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 `s`: unknown argument `mi` for validator `range` (it only has `min`, `max`)
+struct Test {
+ #[validate(range(mi = 2, max = 3))]
+ s: i32,
+}
+
+fn main() {}
diff --git a/validator_derive/tests/compile-fail/range/wrong_arg_type.rs b/validator_derive/tests/compile-fail/range/wrong_arg_type.rs
new file mode 100644
index 0000000..a62a5ff
--- /dev/null
+++ b/validator_derive/tests/compile-fail/range/wrong_arg_type.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 `s`: invalid argument type for `min` of `range` validator: only integers are allowed
+struct Test {
+ #[validate(range(min = "2", max = 3))]
+ s: i32,
+}
+
+fn main() {}
diff --git a/validator_derive/tests/compile-fail/range/wrong_type.rs b/validator_derive/tests/compile-fail/range/wrong_type.rs
new file mode 100644
index 0000000..e341364
--- /dev/null
+++ b/validator_derive/tests/compile-fail/range/wrong_type.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 `s`: Validator `range` can only be used on number types but found `String`
+struct Test {
+ #[validate(range(min = 10.0, max = 12.0))]
+ s: String,
+}
+
+fn main() {}