Crate jsonschema_valid_compat[][src]

jsonschema-valid

A simple crate to perform JSON Schema validation.

Supports JSON Schema drafts 4, 6, and 7.

Example:

The following example validates some JSON data against a draft 6 JSON schema.

let schema: Value = serde_json::from_str(schema_json)?;
let data: Value = serde_json::from_str(your_json_data)?;
let cfg = jsonschema_valid::Config::from_schema(&schema, Some(schemas::Draft::Draft6))?;
// Validate the schema itself
assert!(cfg.validate_schema().is_ok());
// Validate a JSON instance against the schema
assert!(cfg.validate(&data).is_ok());

Modules

schemas

Implementations of the different drafts of JSON schema.

Structs

Config

A structure to hold configuration for a validation run.

ValidationError

An error that can occur during validation.

Functions

validate

Validates a given JSON instance against a given JSON schema, returning the errors, if any. draft may provide the schema draft to use. If not provided, it will be determined automatically from the schema.

Type Definitions

ErrorIterator

An Iterator over ValidationError objects. The main method by which validation errors are returned to the user.