JSON-Schema-Validate
view release on metacpan or search on metacpan
lib/JSON/Schema/Validate.pm view on Meta::CPAN
=item * C<unevaluatedItems> / C<unevaluatedProperties>
Both C<unevaluatedItems> and C<unevaluatedProperties> are enforced using annotation produced by earlier keyword evaluations within the same schema object, matching draft 2020-12 semantics.
=item * Error reporting and pointers
Each error object contains both:
=over 4
=item *
C<path> â a JSON Pointer-like path to the failing location in the instance (e.g. C<#/properties~1s/oneOf~11/properties~1classes/0>).
=item *
C<schema_pointer> â a JSON Pointer into the root schema that identifies the keyword which emitted the error (e.g.
C<#/properties~1s/oneOf~11/properties~1classes/items/allOf~10/then/voting_right>).
=back
Messages for C<required> errors also list the full required set and the keys actually present at that location to help debug combinators such as C<anyOf>/C<oneOf>/C<if>/C<then>/C<else>.
=item * RFC rigor and media types
L<URI>/C<IRI> and mediaâtype parsing is intentionally pragmatic rather than fully RFC-complete. For example, C<uri>, C<iri>, and C<uri-reference> use strict but heuristic regexes; C<contentMediaType> validates UTF-8 for C<text/*; charset=utf-8> and...
=item * Compilation vs. Interpretation
Both code paths are correct by design. The interpreter is simpler and great while developing a schema; toggle C<< ->compile >> when moving to production or after the schema stabilises. You may enable compilation lazily (call C<compile> any time) or e...
=back
=head1 WHY ENABLE C<COMPILE>?
When C<compile> is ON, the validator precompiles a tiny Perl closure for each schema node. At runtime, those closures:
=over 4
=item * avoid repeated hash lookups for keyword presence/values;
=item * skip dispatch on absent keywords (branchless fast paths);
=item * reuse precompiled child validators (arrays/objects/combinators);
=item * reduce allocator churn by returning small, fixed-shape result hashes.
=back
In practice this improves steady-state throughput (especially for large/branchy schemas, or hot validation loops) and lowers tail latency by minimising per-instance work. The trade-offs are:
=over 4
=item * a one-time compile cost per node (usually amortised quickly);
=item * a small memory footprint for closures (one per visited node).
=back
If you only validate once or twice against a tiny schema, compilation will not matter; for services, batch jobs, or streaming pipelines it typically yields a noticeable speedup. Always benchmark with your own schema+data.
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<perl>, L<Time::Piece>, L<DateTime>, L<DateTime::Format::ISO8601>, L<Regexp::Common>, L<Net::IDN::Encode>, L<JSON::PP>
L<JSON::Schema>, L<JSON::Validator>
L<python-jsonschema|https://github.com/python-jsonschema/jsonschema>,
L<fastjsonschema|https://github.com/horejsek/python-fastjsonschema>,
L<Pydantic|https://docs.pydantic.dev>,
L<RapidJSON Schema|https://rapidjson.org/md_doc_schema.html>
L<https://json-schema.org/specification>
=head1 COPYRIGHT & LICENSE
Copyright(c) 2025 DEGUEST Pte. Ltd.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=cut
( run in 0.547 second using v1.01-cache-2.11-cpan-39bf76dae61 )