NAME
std/data/json/schema/format - JSON Schema format validators.
SYNOPSIS
from std/data/json/schema/format import FormatRegistry;
let formats := new FormatRegistry();
formats.register( "slug", fn value -> value ~ /^[a-z0-9-]+$/ );
say( formats.check( "slug", "release-2026" ) );
IMPLEMENTATION SUPPORT
This Pure Zuzu module is supported by all implementations of ZuzuScript.
DESCRIPTION
std/data/json/schema/format provides the format registry used by the JSON Schema validator. A registry maps format names to callables. A callable receives the instance value and returns true when the value satisfies the format.
The default registry includes validators for the standard JSON Schema formats: date-time, date, time, duration, email, idn-email, hostname, idn-hostname, ipv4, ipv6, uri, uri-reference, iri, iri-reference, uuid, json-pointer, relative-json-pointer, and regex.
Format checking is controlled by the validator. By default format is annotation-only; pass format_assert: true to JSONSchema to make it assertive.
EXPORTS
Classes
FormatRegistryRegistry of named format validators.
register( name, validator )Registers
validatorundernameand returns the registry. The validator may be any callable value.has( name )Returns true when a validator has been registered for
name.check( name, value )Returns the result of the named validator. Unknown names return
false; the higher-level validator decides whether an unknown format is ignored or reported as an error.
PORTABILITY
Some validators rely on the host runtime's regular expression engine. The validators are intentionally conservative and do not attempt full RFC-grade parsing for every format.
COPYRIGHT AND LICENCE
std/data/json/schema/format is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.