Skip to main content

overlay_constraints

Function overlay_constraints 

Source
pub fn overlay_constraints(base: &Value, overlay: &Value) -> Value
Expand description

Overlay additional constraints from one schema onto another.

Copies properties, required, and validation keywords (minLength, maxLength, minimum, maximum, pattern, format) from overlay into a clone of base. Existing base values are preserved.

let base = serde_json::json!({"type": "object", "properties": {"name": {"type": "string"}}});
let overlay = serde_json::json!({"properties": {"name": {"minLength": 2}}, "required": ["name"]});
let result = vld_openapi::validator::overlay_constraints(&base, &overlay);
assert!(vld_openapi::validator::is_required(&result, "name"));