Expand description
Checking a value against a JSON Schema type of a bundle (spec core.md
§7.3), for tools that build a payload from JSON and were never compiled
against the contract (#671).
The subset is small on purpose (§7.3): type, properties,
required, additionalProperties, items, prefixItems, enum,
const, the numeric bounds, minLength/maxLength,
minItems/maxItems, $ref and oneOf/anyOf, plus boolean
schemas. None of them needs a regular-expression dialect, which is why
the subset refuses pattern. This module implements those keywords as
JSON Schema 2020-12 defines them, and nothing else: an annotation is
ignored, and a keyword outside the subset cannot occur, because a
contract that uses one does not load (E037).
The core requires no owner to evaluate a schema (§5.1, “The request”), and a caller MUST NOT depend on a refusal of what the schema refuses: a writer sends only what its schema declares (§9.8). This is how a tool keeps that side of the rule before it sends.
Structs§
- Violation
- One way a value fails its schema.
Functions§
- resolve_
ref - Resolves a
$refwritten indoc, one ofbundle’s JSON Schema documents (§9.4): the file part names another of them by its stem (the last path segment, without.json), and an empty one namesdocitself. Returns the schema it points at and the document holding it, from which that schema’s own$refs resolve. - satisfies
- Whether
valuesatisfiesschema, one schema position insidedoc, a JSON Schema document ofbundle: its$refs resolve fromdoc, asresolve_refsays. - validate
- Checks
valueagainst the JSON Schema typety, a canonical type reference ofbundle({"kind": "jsonschema", "name", "schema"}).Errlists every violation found, in the order met; a type that is not a JSON Schema type of the bundle, or a$refthat resolves to nothing, is one violation at the root.