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 | |
| download | validator-c5c76fac8726d53988092d71c818d38f12e8348e.tar.bz2 | |
Initial commit
Diffstat (limited to 'validator_derive/tests/compile-fail')
12 files changed, 180 insertions, 0 deletions
diff --git a/validator_derive/tests/compile-fail/custom_not_string.rs b/validator_derive/tests/compile-fail/custom_not_string.rs new file mode 100644 index 0000000..e576c5c --- /dev/null +++ b/validator_derive/tests/compile-fail/custom_not_string.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 for `custom` validator: only strings are allowed +struct Test { + #[validate(custom = 2)] + s: String, +} + +fn main() {} 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() {} diff --git a/validator_derive/tests/compile-fail/no_validations.rs b/validator_derive/tests/compile-fail/no_validations.rs new file mode 100644 index 0000000..0a65bdd --- /dev/null +++ b/validator_derive/tests/compile-fail/no_validations.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`: it needs at least one validator +struct Test { + #[validate()] + s: String, +} + +fn main() {} 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() {} |
