Repository navigation
The documentation is now at https://hyperjump.io/json-schema-formats/.
What's new
-
assertfunctions and error classes. Each format has anassertfunction, likeassertDate, that throws an error of its own class when a value isn't valid. The error says what's wrong, which part of the value it's in, and where. See Find what's wrong. -
Formats from the JSON Schema and OpenAPI format registries. The registry formats that say exactly what's valid:
- For strings:
date-time-local,time-local,ipv4-cidr,ipv6-cidr,language,http-date,media-range,sf-binary,sf-boolean,sf-string, andsf-token. - For numbers:
int8,int16,int32,uint8,uint16,uint32,double-int,sf-integer, andsf-decimal.
See Registry formats.
- For strings:
-
Scheme rules for URIs and IRIs.
isUri,isUriReference,isIri, andisIriReferencecome from@hyperjump/uriv2, which checks the rules ofhttp,https,file,urn,tag,data, anddid, as well as the generic syntax. See URIs and IRIs. -
Types for URIs and IRIs. The URI and IRI functions are type guards, and the package exports the types that they narrow to:
Uri,UriReference,Iri, andIriReference. It also exportsInvalidUriErrorandInvalidIriError. -
Faster. For a valid value,
isDateandisDateTimeare 7 to 9 times as fast as in 1.1.0,isDateTimeExt5 times, andisAsciiIdnandisEmailabout twice.
Changes
- Scheme rules make some URIs and IRIs that 1.1.0 accepted not valid, like
http:///a, which has no host, andurn:uuid:x. A scheme that@hyperjump/uridoesn't know is still checked with the generic syntax only. isIdnEmailthrows anErrorfor an address literal with a tag other thanIPv6, likeada@[x-example:abc], asisEmaildoes. It accepted one before.isEmailandisIdnEmailreturnfalsefor anIPv6address literal that isn't an IPv6 address.isEmailthrew, andisIdnEmailaccepted it.idn-hostnameis updated to 16, which is Unicode 16.0.- The package declares the Node.js versions that it supports: 22.12 or later, but not 23.