Allow validate (but not schemars) attributes to have extra values where necessary

This commit is contained in:
Graham Esau 2024-08-28 09:59:24 +01:00
parent a85f0fc7bc
commit 56cdd45c5a
5 changed files with 63 additions and 24 deletions

View file

@ -30,6 +30,9 @@ pub struct Struct4(
regex(path = "baz"),
regex(pattern = "baz"),
phone,
email(code = "code_str", message = "message"),
email = "foo",
email,
email,
url
)]

View file

@ -82,10 +82,28 @@ error: `schemars(regex(...))` attribute requires `pattern = ...`
30 | regex(path = "baz"),
| ^^^^^^^^^^^^^^^^^^^
error: schemars attribute cannot contain both `url` and `email`
--> tests/ui/invalid_validation_attrs.rs:34:9
error: unexpected value of schemars email attribute item
--> tests/ui/invalid_validation_attrs.rs:33:14
|
34 | url
33 | email(code = "code_str", message = "message"),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: unexpected value of schemars email attribute item
--> tests/ui/invalid_validation_attrs.rs:34:15
|
34 | email = "foo",
| ^^^^^^^
error: duplicate schemars attribute item `email`
--> tests/ui/invalid_validation_attrs.rs:36:9
|
36 | email,
| ^^^^^
error: schemars attribute cannot contain both `url` and `email`
--> tests/ui/invalid_validation_attrs.rs:37:9
|
37 | url
| ^^^
error: unknown schemars attribute `phone`

View file

@ -34,7 +34,7 @@ pub struct Struct {
contains_str2: String,
#[validate(email)]
email_address: String,
#[validate(url)]
#[validate(url(code = "code_str", message = "message"))]
homepage: String,
#[validate(length(min = 1, max = 100))]
non_empty_str: String,