std/json-schema/validate
std/json-schema/src/validate.trb
extend JsonSchema
extend JsonSchema
Validation: a schema and a document are walked together, and one ValidationError is collected for every keyword the
document fails. A subschema is judged by running it and looking at whether it found anything, so the errors of a
failed anyOf branch are known without a second walk.
fn validate
fn validate(instance: JsonValue): Validation
Checks instance against the schema and answers what it failed: valid and one ValidationError per
failed keyword, each with the keyword, its place in the schema, the place in the document and a message. A
document that fails nothing has no errors.
Examples
const schema = JsonSchema.read("\{\"items\": \{\"type\": \"integer\"\}\}")?
const result = schema.validate(Json().parse("[1, \"two\", 3]")?)
print result.valid
print result