Skip to main content

evaluate

Function evaluate 

Source
pub fn evaluate(schema: &Value, instance: &Value) -> Evaluation
Expand description

Evaluate instance against schema and return structured validation output. Draft is detected automatically.

Returns an Evaluation containing detailed validation results in JSON Schema Output v1 format, including annotations and errors across the entire validation tree.

§Examples

use serde_json::json;

let schema = json!({"type": "string", "minLength": 3});
let instance = json!("foo");
let evaluation = jsonschema::evaluate(&schema, &instance);
assert!(evaluation.flag().valid);

§Panics

This function panics if an invalid schema is passed.

This function must not be called from within an async runtime if the schema contains external references that require network requests, or it will panic when attempting to block. Use async_validator_for for async contexts, or run this in a separate blocking thread via tokio::task::spawn_blocking.