Skip to content

JsonSchemaValidator

Rico Suter edited this page Jan 17, 2020 · 5 revisions

Usage:

var data = "{...}";
var schema = await JsonSchema.FromJsonAsync("{...}");
var validator = new JsonSchemaValidator();
var result = validator.Validate(data, schema);

If you don't need to customize the validator, you can just call the Validate() method on the schema:

var data = "{...}";
var schema = await JsonSchema.FromJsonAsync("{...}");
var result = schema.Validate(data);

The method Validate(jsonData, schema) returns a collection of validation errors or throws a JsonReaderException exception if the JSON data cannot be processed.