Liking cljdoc? Tell your friends :D

com.blockether.skjema.core

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.

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.
raw docstring

compileclj

(compile schema)
(compile schema opts)

Index a schema once so every $ref, $anchor and $dynamicAnchor in it is already resolved when validation runs.

Options: :base the URI the schema is considered to have been retrieved from :registry a map of absolute URI -> schema for documents this one references. Nothing is fetched; a reference to a document the registry does not carry fails when it is followed. :format-assertion make format assert instead of annotate. The specification leaves that to the caller unless a meta-schema declares the format-assertion vocabulary, which turns it on for that resource whatever this option says.

Index a schema once so every `$ref`, `$anchor` and `$dynamicAnchor` in it is
already resolved when validation runs.

Options:
  `:base`     the URI the schema is considered to have been retrieved from
  `:registry` a map of absolute URI -> schema for documents this one
              references. Nothing is fetched; a reference to a document the
              registry does not carry fails when it is followed.
  `:format-assertion` make `format` assert instead of annotate. The
              specification leaves that to the caller unless a meta-schema
              declares the format-assertion vocabulary, which turns it on
              for that resource whatever this option says.
sourceraw docstring

compiled?clj

(compiled? x)
source

valid?clj

(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.
sourceraw docstring

validateclj

(validate schema instance)
(validate schema instance opts)

Validate instance against a compiled schema (or a raw one, compiled on the spot) and answer the specification's BASIC output: {:valid true}, or {:valid false :errors [...]} where every error carries :instanceLocation, :keywordLocation, :absoluteKeywordLocation and a human :error. The keys are the specification's own, so writing the answer out as JSON is one call.

Validate `instance` against a compiled schema (or a raw one, compiled on the
spot) and answer the specification's BASIC output: `{:valid true}`, or
`{:valid false :errors [...]}` where every error carries `:instanceLocation`,
`:keywordLocation`, `:absoluteKeywordLocation` and a human `:error`. The keys
are the specification's own, so writing the answer out as JSON is one call.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close