JSON Schema 2020-12 evaluation.
The evaluator answers ANNOTATIONS as well as errors, from the first line and
not as a later addition: unevaluatedProperties and unevaluatedItems are
defined in terms of what the ADJACENT keywords and the in-place applicators
already evaluated, so a validator that answers only true/false cannot grow
them without being rewritten. Every evaluation therefore returns
{:valid? :props :items :errors} - the property names and item indices that
were evaluated AT THIS INSTANCE LOCATION, plus every fault found underneath.
Two kinds of applicator, and the difference is the whole design:
$ref, $dynamicRef, allOf, anyOf, oneOf, if/then/
else, dependentSchemas) apply another schema to the SAME instance
location, so their annotations belong to this location and bubble up.properties, patternProperties, additionalProperties, items,
prefixItems, contains, propertyNames) apply to a location BELOW, so
their annotations stay there and this location records only which member
was covered.Identifiers are resolved once, when the schema is compiled: $id moves the
base URI, $anchor and $dynamicAnchor name a place inside it, and the
index that comes out is what $ref and $dynamicRef read. Nothing is
fetched over the network, ever - a schema that references a document the
caller did not supply is a compile error, not a silent pass.
JSON Schema 2020-12 evaluation.
The evaluator answers ANNOTATIONS as well as errors, from the first line and
not as a later addition: `unevaluatedProperties` and `unevaluatedItems` are
defined in terms of what the ADJACENT keywords and the in-place applicators
already evaluated, so a validator that answers only true/false cannot grow
them without being rewritten. Every evaluation therefore returns
`{:valid? :props :items :errors}` - the property names and item indices that
were evaluated AT THIS INSTANCE LOCATION, plus every fault found underneath.
Two kinds of applicator, and the difference is the whole design:
- IN PLACE (`$ref`, `$dynamicRef`, `allOf`, `anyOf`, `oneOf`, `if`/`then`/
`else`, `dependentSchemas`) apply another schema to the SAME instance
location, so their annotations belong to this location and bubble up.
- CHILD (`properties`, `patternProperties`, `additionalProperties`, `items`,
`prefixItems`, `contains`, `propertyNames`) apply to a location BELOW, so
their annotations stay there and this location records only which member
was covered.
Identifiers are resolved once, when the schema is compiled: `$id` moves the
base URI, `$anchor` and `$dynamicAnchor` name a place inside it, and the
index that comes out is what `$ref` and `$dynamicRef` read. Nothing is
fetched over the network, ever - a schema that references a document the
caller did not supply is a compile error, not a silent pass.(compile-schema schema)(compile-schema schema opts)Compile and index a schema once so repeated validation does not walk its
structure. Options: :base, :registry, and :format-assertion. Referenced
documents are resolved only from the supplied registry.
Compile and index a schema once so repeated validation does not walk its structure. Options: `:base`, `:registry`, and `:format-assertion`. Referenced documents are resolved only from the supplied registry.
(read-schema source)Read a JSON Schema from JSON text, a Path, File, URL/resource, InputStream, or Reader. Objects keep their JSON string keys.
Read a JSON Schema from JSON text, a Path, File, URL/resource, InputStream, or Reader. Objects keep their JSON string keys.
(valid? schema instance)(valid? schema instance opts)True when the instance validates. Use validate when the reason matters -
this asks for the verdict alone, so evaluation stops at the first keyword
that refuses and no error is built on the way.
True when the instance validates. Use `validate` when the reason matters - this asks for the verdict alone, so evaluation stops at the first keyword that refuses and no error is built on the way.
(validate schema instance)(validate schema instance opts)Validate instance against a compiled schema (or a raw one, compiled on the
spot). Invalid answers preserve JSON Schema BASIC-output locations and add
:keyword plus keyword-specific :params, so a caller can render or act on
an error without parsing its human :error string. The entire answer is a
JSON value.
Validate `instance` against a compiled schema (or a raw one, compiled on the spot). Invalid answers preserve JSON Schema BASIC-output locations and add `:keyword` plus keyword-specific `:params`, so a caller can render or act on an error without parsing its human `:error` string. The entire answer is a JSON value.
(write-schema value)Render a schema or validation result as compact JSON.
Render a schema or validation result as compact JSON.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |