Skip to main content

validate_json

Function validate_json 

Source
pub fn validate_json(
    schema: &Value,
    instance: &Value,
) -> Result<(), Vec<String>>
Expand description

Validate instance against JSON Schema schema, returning the list of violation messages (empty Ok means valid).

The schema’s draft is auto-detected, defaulting to 2020-12 when no $schema is present (matching MCP). String format assertions are not enforced (the default for this validator). If schema itself cannot be compiled, validation is skipped and Ok(()) is returned after logging a warning—a malformed schema is a server configuration bug and must not break tool calls.

§Errors

Returns the collected violation messages when instance does not conform.