immutable properties complete and tested
This commit is contained in:
@ -179,6 +179,34 @@ impl<'a> ValidationContext<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
if !self.response {
|
||||
if let Some(compiled_props) = self.schema.compiled_properties.get() {
|
||||
for (key, sub_schema) in compiled_props {
|
||||
if sub_schema.is_immutable() && obj.contains_key(key) {
|
||||
result.errors.push(ValidationError {
|
||||
code: "IMMUTABLE_PROPERTY_VIOLATION".to_string(),
|
||||
values: Some(IndexMap::from([
|
||||
("property_name".to_string(), key.to_string()),
|
||||
])),
|
||||
path: self.join_path(key),
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if let Some(props) = &self.schema.properties {
|
||||
for (key, sub_schema) in props {
|
||||
if sub_schema.is_immutable() && obj.contains_key(key) {
|
||||
result.errors.push(ValidationError {
|
||||
code: "IMMUTABLE_PROPERTY_VIOLATION".to_string(),
|
||||
values: Some(IndexMap::from([
|
||||
("property_name".to_string(), key.to_string()),
|
||||
])),
|
||||
path: self.join_path(key),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(props) = &self.schema.properties {
|
||||
for (key, sub_schema) in props {
|
||||
if self.overrides.contains(key) {
|
||||
@ -228,6 +256,7 @@ impl<'a> ValidationContext<'a> {
|
||||
HashSet::new(),
|
||||
self.extensible,
|
||||
self.reporter,
|
||||
self.response,
|
||||
);
|
||||
|
||||
result.merge(ctx.validate()?);
|
||||
|
||||
Reference in New Issue
Block a user