immutable properties complete and tested

This commit is contained in:
2026-07-21 16:25:12 -04:00
parent ff4b9cd24d
commit 350fe29fef
7 changed files with 338 additions and 88 deletions

View File

@ -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()?);