diff options
| author | Vincent Prouillet | 2016-12-27 14:31:17 +0900 |
|---|---|---|
| committer | Vincent Prouillet | 2016-12-28 11:49:43 +0900 |
| commit | c5c76fac8726d53988092d71c818d38f12e8348e (patch) | |
| tree | fffc8d3c5f369da2b935d118a2118d2fcca905a5 /validator_derive/tests/compile-fail/length | |
| download | validator-c5c76fac8726d53988092d71c818d38f12e8348e.tar.bz2 | |
Initial commit
Diffstat (limited to 'validator_derive/tests/compile-fail/length')
5 files changed, 75 insertions, 0 deletions
diff --git a/validator_derive/tests/compile-fail/length/equal_and_min_max_set.rs b/validator_derive/tests/compile-fail/length/equal_and_min_max_set.rs new file mode 100644 index 0000000..cc6654c --- /dev/null +++ b/validator_derive/tests/compile-fail/length/equal_and_min_max_set.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`: both `equal` and `min` or `max` have been set in `length` validator: probably a mistake +struct Test { + #[validate(length(min = 1, equal = 2))] + s: String, +} + +fn main() {} diff --git a/validator_derive/tests/compile-fail/length/no_args.rs b/validator_derive/tests/compile-fail/length/no_args.rs new file mode 100644 index 0000000..35a44df --- /dev/null +++ b/validator_derive/tests/compile-fail/length/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 `length` requires at least 1 argument out of `min`, `max` and `equal` +struct Test { + #[validate(length())] + s: String, +} + +fn main() {} diff --git a/validator_derive/tests/compile-fail/length/unknown_arg.rs b/validator_derive/tests/compile-fail/length/unknown_arg.rs new file mode 100644 index 0000000..d8e6185 --- /dev/null +++ b/validator_derive/tests/compile-fail/length/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 `eq` for validator `length` (it only has `min`, `max`, `equal`) +struct Test { + #[validate(length(eq = 2))] + s: String, +} + +fn main() {} diff --git a/validator_derive/tests/compile-fail/length/wrong_arg_type.rs b/validator_derive/tests/compile-fail/length/wrong_arg_type.rs new file mode 100644 index 0000000..4d3f602 --- /dev/null +++ b/validator_derive/tests/compile-fail/length/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 `length` validator: only integers are allowed +struct Test { + #[validate(length(min = "2"))] + s: String, +} + +fn main() {} diff --git a/validator_derive/tests/compile-fail/length/wrong_type.rs b/validator_derive/tests/compile-fail/length/wrong_type.rs new file mode 100644 index 0000000..e8a28ca --- /dev/null +++ b/validator_derive/tests/compile-fail/length/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 `length` can only be used on types `String` or `Vec` but found `usize` +struct Test { + #[validate(length())] + s: usize, +} + +fn main() {} |
