Skip to main content

validate

Function validate 

Source
pub fn validate(schema: &Value) -> Result<(), ValidationError<'_>>
Expand description

Validate a JSON Schema document against Draft 6 meta-schema and return the first error if any.

§Examples

use serde_json::json;

let schema = json!({
    "type": "string",
    "maxLength": 5
});
assert!(jsonschema::draft6::meta::validate(&schema).is_ok());

// Invalid schema
let invalid_schema = json!({
    "type": "invalid_type"
});
assert!(jsonschema::draft6::meta::validate(&invalid_schema).is_err());

§Errors

Returns the first ValidationError describing why the schema violates the Draft 6 meta-schema.