Process validation attributes in tuple structs

This commit is contained in:
Graham Esau 2021-04-16 13:56:26 +01:00
parent 31a5893d10
commit 9e507272da
3 changed files with 55 additions and 10 deletions

View file

@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Tuple",
"type": "array",
"items": [
{
"type": "integer",
"format": "uint8",
"maximum": 10.0,
"minimum": 0.0
},
{
"type": "boolean"
}
],
"maxItems": 2,
"minItems": 2
}

View file

@ -47,6 +47,17 @@ fn validate() -> TestResult {
test_default_generated_schema::<Struct>("validate")
}
#[derive(Debug, JsonSchema)]
pub struct Tuple(
#[validate(range(max = 10))] u8,
#[validate(required)] Option<bool>,
);
#[test]
fn validate_tuple() -> TestResult {
test_default_generated_schema::<Tuple>("validate_tuple")
}
#[derive(Debug, JsonSchema)]
pub struct NewType(#[validate(range(max = 10))] u8);