Allow setting validation attributes via #[schemars(...)]
This commit is contained in:
parent
c013052f59
commit
7914593d89
17 changed files with 607 additions and 99 deletions
|
@ -22,7 +22,7 @@ error: duplicate serde attribute `deny_unknown_fields`
|
|||
8 | #[schemars(default = 0, foo, deny_unknown_fields, deny_unknown_fields)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unknown schemars container attribute `foo`
|
||||
error: unknown schemars attribute `foo`
|
||||
--> $DIR/invalid_attrs.rs:8:25
|
||||
|
|
||||
8 | #[schemars(default = 0, foo, deny_unknown_fields, deny_unknown_fields)]
|
||||
|
|
9
schemars/tests/ui/invalid_validation_attrs.rs
Normal file
9
schemars/tests/ui/invalid_validation_attrs.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use schemars::JsonSchema;
|
||||
|
||||
#[derive(JsonSchema)]
|
||||
pub struct Struct1(#[validate(regex = 0, foo, length(min = 1, equal = 2, bar))] String);
|
||||
|
||||
#[derive(JsonSchema)]
|
||||
pub struct Struct2(#[schemars(regex = 0, foo, length(min = 1, equal = 2, bar))] String);
|
||||
|
||||
fn main() {}
|
29
schemars/tests/ui/invalid_validation_attrs.stderr
Normal file
29
schemars/tests/ui/invalid_validation_attrs.stderr
Normal file
|
@ -0,0 +1,29 @@
|
|||
error: expected validate regex attribute to be a string: `regex = "..."`
|
||||
--> $DIR/invalid_validation_attrs.rs:4:39
|
||||
|
|
||||
4 | pub struct Struct1(#[validate(regex = 0, foo, length(min = 1, equal = 2, bar))] String);
|
||||
| ^
|
||||
|
||||
error: unknown schemars attribute `foo`
|
||||
--> $DIR/invalid_validation_attrs.rs:7:42
|
||||
|
|
||||
7 | pub struct Struct2(#[schemars(regex = 0, foo, length(min = 1, equal = 2, bar))] String);
|
||||
| ^^^
|
||||
|
||||
error: expected schemars regex attribute to be a string: `regex = "..."`
|
||||
--> $DIR/invalid_validation_attrs.rs:7:39
|
||||
|
|
||||
7 | pub struct Struct2(#[schemars(regex = 0, foo, length(min = 1, equal = 2, bar))] String);
|
||||
| ^
|
||||
|
||||
error: schemars attribute cannot contain both `equal` and `min`
|
||||
--> $DIR/invalid_validation_attrs.rs:7:63
|
||||
|
|
||||
7 | pub struct Struct2(#[schemars(regex = 0, foo, length(min = 1, equal = 2, bar))] String);
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: unknown item in schemars length attribute
|
||||
--> $DIR/invalid_validation_attrs.rs:7:74
|
||||
|
|
||||
7 | pub struct Struct2(#[schemars(regex = 0, foo, length(min = 1, equal = 2, bar))] String);
|
||||
| ^^^
|
Loading…
Add table
Add a link
Reference in a new issue