Skip to main content

Module check

Module check 

Source
Expand description

Checking one JSON value against one Schema.

The walk is ordinary; the parts worth reading are the three places where the specification says to be permissive and it would be easy to be strict instead. An object property no schema declares is kept. A $type outside an open union’s refs is kept. A knownValues list is not a constraint at all. Each of those is a record written by a client that knows a newer version of a lexicon than this server does, and refusing any of them turns a schema addition into an outage.

Errors carry a path — artifacts[2], object.a — because the whole value of validating on write is that the client is told which field is wrong while it still has the field in hand.

Structs§

InvalidRecord
Why a record does not satisfy its lexicon.

Constants§

MAX_SCHEMA_DEPTH
How deep a schema may nest before the walk gives up.
ROOT 🔒
The root of an error path, for a failure about the record as a whole.

Functions§

check 🔒
Checks a record body against a record definition’s schema.
check_blob 🔒
Checks a blob value.
check_bytes 🔒
Checks a bytes value: {"$bytes": "<base64>"}.
check_cid_link 🔒
Checks a cid-link value: {"$link": "<cid>"}.
check_integer 🔒
Checks an integer and its bounds.
check_object 🔒
Checks an object: required, nullable, declared properties, and the rest.
check_string 🔒
Checks a string, its lengths, its enumeration and its format.
check_union 🔒
Checks a union: an object whose $type chooses the schema.
check_unknown 🔒
Checks an unknown value.
check_value 🔒
The recursive step.
child 🔒
Extends an error path with a property name.
decoded_length 🔒
How many bytes a base64 string of this many characters decodes to.
index 🔒
Extends an error path with an array index.
kind_of 🔒
Names the JSON kind of a value, for an error message.
mime_matches 🔒
Whether a MIME type matches one accept pattern.
qualify 🔒
Rewrites a ref into the document#def form a $type would be written in.