Skip to content
@deckyard/jsonschema

Formats

Draft 2020-12 treats format as an annotation: by default {"format": "email"} accepts any string. Turn assertion on per schema:

jennifer
def s as jsonschema.Schema init jsonschema.assertFormats(jsonschema.compile($schema), true);

A schema whose meta-schema lists the format-assertion vocabulary has it on from the start.

Only strings are checked; a number passes "format": "email".

Checked

FormatAccepts
date-timeRFC 3339 date-time; a leap second only at 23:59:60 UTC
dateYYYY-MM-DD, a day that exists
timeRFC 3339 time with an offset
durationISO 8601 duration as RFC 3339 appendix A defines it
emailRFC 5321 mailbox: dot-atom or quoted local part, host name or address literal
hostnameRFC 1123 labels, 63 characters each, 253 in all
ipv4dotted quad, no leading zeros
ipv6RFC 4291 text form, with an optional trailing IPv4 address, no zone
uriRFC 3986 URI with a scheme
uri-referenceRFC 3986 URI or relative reference
uuidhyphenated hex
json-pointerRFC 6901
relative-json-pointerrelative JSON Pointer
regexa pattern RE2 compiles (not ECMA-262: see Validating)

Not checked

idn-email, idn-hostname, iri, iri-reference and uri-template pass any string, as do formats the deck does not know. hostname checks an xn-- label for syntax only: decoding Punycode against the IDNA tables is not done.