std/json-schema

JSON Schema as a format, written in TorbScript: JsonSchema reads a schema of the in-place keywords of draft 2020-12 from JSON and validates a JsonValue document against it.

const schema = JsonSchema.read(text)?
const result = schema.validate(document)
for problem in result.errors {
  print problem
}

One model for the versions. The model is the current draft, 2020-12; the earlier drafts will be read into it, as ROADMAP's table of format versions says. This first step has the in-place keywords only: those that look at the value in front of them or hand a part of it to a subschema. $ref, $dynamicRef, unevaluatedItems and unevaluatedProperties, and a $schema of another draft, are refused with a JsonSchemaError that names them, and so is a pattern that RE2 cannot run: a schema this package reads is a schema it checks in full.

Numbers are Float64, as in JsonValue: 1.0 is an integer, and numbers that need more than 53 bits to tell apart are not told apart.

Modules

Everything