Add associative map constraints and range refinement

This commit is contained in:
2026-08-14 06:26:15 +09:00
parent 8198b615a8
commit cc6ab40807
52 changed files with 8951 additions and 6918 deletions
+27
View File
@@ -84,6 +84,16 @@ fn object(fields: &Map<String, Value>) -> Result<HostValue, String> {
default,
})
}
"Map" => {
let value = fields
.get("value")
.ok_or_else(|| String::from("Map descriptor requires `value`"))?;
Ok(HostValue::MapConstraint {
value: Box::new(from_json(value)?),
constraints,
default,
})
}
"Abstract" => Ok(HostValue::Abstract {
constraints,
default,
@@ -217,6 +227,23 @@ mod tests {
);
}
#[test]
fn converts_map_schema_descriptors() {
let value = serde_json::json!({
"$decodal": "Map",
"value": { "$decodal": "Bool" },
"default": {},
});
assert_eq!(
from_json(&value).unwrap(),
HostValue::MapConstraint {
value: Box::new(HostValue::bool_type()),
constraints: Vec::new(),
default: Some(Box::new(HostValue::object([] as [(&str, HostValue); 0]))),
}
);
}
#[test]
fn rejects_null_values() {
assert!(