pub fn validate<'i>(
schema: &Value,
instance: &'i Value,
) -> Result<(), ValidationError<'i>>Expand description
Validate instance against schema and return the first error if any. Draft is detected automatically.
§Examples
use serde_json::json;
let schema = json!({"maxLength": 5});
let instance = json!("foo");
assert!(jsonschema::validate(&schema, &instance).is_ok());§Errors
Returns the first ValidationError encountered when instance violates schema.
§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.