schema: verify property strings w/ new serde code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
12da5121ff
commit
f6e089555e
@ -606,7 +606,11 @@ impl<'de, 'i> de::MapAccess<'de> for MapAccess<'de, 'i> {
|
|||||||
.ok_or(Error::msg("bad default key"))?;
|
.ok_or(Error::msg("bad default key"))?;
|
||||||
(Cow::Borrowed(key), Some(schema))
|
(Cow::Borrowed(key), Some(schema))
|
||||||
}
|
}
|
||||||
None => return Err(Error::msg("missing key")),
|
None => {
|
||||||
|
return Err(Error::msg(
|
||||||
|
"value without key, but schema does not define a default key",
|
||||||
|
))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let schema = schema.map(|(_optional, schema)| schema);
|
let schema = schema.map(|(_optional, schema)| schema);
|
||||||
|
@ -472,7 +472,7 @@ impl StringSchema {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ApiStringFormat::PropertyString(subschema) => {
|
ApiStringFormat::PropertyString(subschema) => {
|
||||||
subschema.parse_property_string(value)?;
|
crate::de::verify::verify(subschema, value)?;
|
||||||
}
|
}
|
||||||
ApiStringFormat::VerifyFn(verify_fn) => {
|
ApiStringFormat::VerifyFn(verify_fn) => {
|
||||||
verify_fn(value)?;
|
verify_fn(value)?;
|
||||||
|
@ -158,7 +158,7 @@ fn verify_nested_property1() -> Result<(), Error> {
|
|||||||
&value,
|
&value,
|
||||||
&[(
|
&[(
|
||||||
"ps1",
|
"ps1",
|
||||||
"Value without key, but schema does not define a default key.",
|
"value without key, but schema does not define a default key",
|
||||||
)],
|
)],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@ -172,7 +172,11 @@ fn verify_nested_property2() -> Result<(), Error> {
|
|||||||
test_verify(
|
test_verify(
|
||||||
&NESTED_PROPERTY_SCHEMA,
|
&NESTED_PROPERTY_SCHEMA,
|
||||||
&value,
|
&value,
|
||||||
&[("ps1/abc", "schema does not allow additional properties.")],
|
&[
|
||||||
|
("ps1/abc", "schema does not allow additional properties"),
|
||||||
|
("ps1/prop1", "property is missing and it is not optional"),
|
||||||
|
("ps1/prop3", "property is missing and it is not optional"),
|
||||||
|
],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -186,8 +190,8 @@ fn verify_nested_property3() -> Result<(), Error> {
|
|||||||
&NESTED_PROPERTY_SCHEMA,
|
&NESTED_PROPERTY_SCHEMA,
|
||||||
&value,
|
&value,
|
||||||
&[
|
&[
|
||||||
("ps1/prop1", "parameter is missing and it is not optional."),
|
("ps1/prop1", "property is missing and it is not optional"),
|
||||||
("ps1/prop3", "parameter is missing and it is not optional."),
|
("ps1/prop3", "property is missing and it is not optional"),
|
||||||
],
|
],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user