Changes for version v0.2.0 - 2025-11-10
- Core Implementation
- Full support for JSON Schema Draft 2020-12, including:
- $id / $anchor / $ref with external & fragment resolution,
- $dynamicAnchor / $dynamicRef with correct dynamic scope lookup.
- Recursion safety implemented via (schema_pointer, instance_address) pairs.
- Comprehensive keyword coverage: type (including unions with inline schemas), const, enum, multipleOf (float-tolerant), numeric bounds, length and pattern, prefixItems/items, contains(min/max), uniqueItems, unevaluatedItems, properties / patternProperties / additionalProperties, propertyNames, required / dependentRequired / dependentSchemas, unevaluatedProperties, allOf / anyOf / oneOf / not, and if/then/else.
- Unevaluated* keyword handling uses annotation tracking on evaluated nodes (props/items maps), matching spec semantics.
- Full support for JSON Schema Draft 2020-12, including:
- New Features
- Optional ahead-of-time compilation:
- Enables fast-path validation via closures per schema node.
- Use ->compile() or constructor 'compile => 1'.
- Indexes anchors / dynamic anchors for constant-time lookup.
- Content assertions (RFC 8927):
- Enable via ->content_checks() or constructor 'content_assert => 1'.
- Supports contentEncoding (built-in base64), contentMediaType, pluggable media decoders, and contentSchema validation.
- Ships with 'application/json' decoder/validator.
- Built-in format validators:
- Activate via ->register_builtin_formats().
- Provides validators for date/time/duration (ISO8601), email/idn-email, hostname/idn-hostname, IPv4/IPv6, URI/IRI/URI-reference, UUID, JSON Pointer / Relative JSON Pointer, and regex.
- Custom format handlers via ->register_format() or constructor 'format => {}'.
- Tracing and introspection:
- Enable via ->trace().
- Limit / sample with ->trace_limit() and ->trace_sample().
- Retrieve via ->get_trace() (returns a copy).
- Vocabulary enforcement:
- Honors $vocabulary and required entries.
- Unknown vocabularies may be ignored via ->ignore_unknown_required_vocab().
- Optional ahead-of-time compilation:
- API Additions
- Constructor options: compile, content_assert, format (hash reference of callbacks), ignore_unknown_required_vocab, max_errors, normalize_instance, trace, trace_limit, trace_sample, vocab_support (hash reference).
- Methods: compile(), content_checks(), enable_content_checks(), ignore_unknown_required_vocab(), register_content_decoder(), register_format(), register_media_validator(), set_resolver(), set_vocabulary_support(), trace(), trace_limit(), trace_sample(). Accessors: is_* variants and get_trace_limit().
- Error handling: ->error() returns the first JSON::Schema::Validate::Error object (stringifies to '"path: message"'). ->errors() returns an array reference (up to max_errors).
- Behavioral Improvements
- Instance normalisation (enabled by default): round-trips values to enforce strict JSON typing distinct from Perl dual values. Can be disabled via 'normalize_instance => 0'.
- Bug Fixes & Polish
- Added missing dependency declarations (thanks Slaven Rezić, GitLab #1).
- Numeric strictness now based on B::FLAGS (IOK/NOK) for correct JSON semantics.
- UTF-8-aware string lengths via codepoint iteration (not bytes).
- All mutator methods return $self for chained configuration.
- Documentation & Tests
- Expanded POD: constructor options, method semantics, formats, normalisation, vocabulary behavior, recursion notes, unevaluated* examples.
- Test suite now covers: dynamic anchors, external refs, combinators, unevaluated*, content/media assertions, compile vs interpretive modes, trace output, vocabulary validation, and structured errors.
Documentation
JSON Schema Exception
Modules
Lean, recursion-safe JSON Schema validator (Draft 2020-12)
Provides
in lib/JSON/Schema/Validate.pm