s;
package JSON::Schema::Modern; # git description: v0.622-7-gee615857
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Validate data against a schema using a JSON Schema
# KEYWORDS: JSON Schema val
;
no if "$]" >= 5.041009, feature => 'smartmatch';
no feature 'switch';
use Mojo::JSON (); # for JSON_XS, MOJO_NO_JSON_XS environment variables
use Carp qw(croak carp);
use List::Util 1.55 qw(pairs f
y;
use JSON::Schema::Modern::Error;
use JSON::Schema::Modern::Result;
use JSON::Schema::Modern::Document;
use JSON::Schema::Modern::Utilities qw(get_type canonical_uri E abort annotate_self jsonp is_t
use strict;
use warnings;
package JSON::Schema::Modern::ResultNode;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Common code for nodes of a JSON::Schema::Modern::Result
our $VERSION = '0.623';
eOrZeroInt';
use JSON::Schema::Modern::Utilities qw(jsonp json_pointer_type);
use namespace::clean;
has [qw(
instance_location
keyword_location
)] => (
is => 'ro',
isa => json_pointer_type,
my $uri = $initial_schema_uri->clone;
my $fragment = ($uri->fragment//'').(@extra_path ? jsonp($keyword_path, @extra_path) : $keyword_path);
undef $fragment if not length($fragment);
JSON::Schema::Modern::Annotation;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Contains a single annotation from a JSON Schema evaluation
our $VERSION = '0.623';
use 5.020;
use Moo;
with 'JSON
ny;
use Types::Standard 'Bool';
use Carp 'croak';
use namespace::clean;
# https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.7.7.1
has annotation => (
is => 'ro',
required =>
NAME
JSON::Schema::Modern::Annotation - Contains a single annotation from a JSON Schema evaluation
=head1 VERSION
version 0.623
=head1 SYNOPSIS
use JSON::Schema::Modern;
my $js = JSON::Schem
use strict;
use warnings;
package JSON::Schema::Modern::Utilities;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Internal utilities for JSON::Schema::Modern
our $VERSION = '0.623';
use 5.020;
u
calar::Util 'looks_like_number';
use Storable 'dclone';
use Feature::Compat::Try;
use Mojo::JSON ();
use JSON::PP ();
use Types::Standard qw(Str InstanceOf);
use namespace::clean;
use Exporter 'impor
qw(
is_type
get_type
is_bool
is_schema
is_bignum
is_equal
is_elements_unique
jsonp
unjsonp
local_annotations
canonical_uri
E
A
abort
assert_keyword_exists
assert_keywor
kage JSON::Schema::Modern::Error;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Contains a single error from a JSON Schema evaluation
our $VERSION = '0.623';
use 5.020;
use Moo;
with 'JSON::Sch
head1 NAME
JSON::Schema::Modern::Error - Contains a single error from a JSON Schema evaluation
=head1 VERSION
version 0.623
=head1 SYNOPSIS
use JSON::Schema::Modern;
my $js = JSON::Schema::Mo
ocation;
my $errors_encoded = encode_json(\@errors);
=head1 DESCRIPTION
An instance of this class holds one error from evaluating a JSON Schema with
L<JSON::Schema::Modern>.
=head1 ATTRIBUTES
=
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary::Validation;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Implementation of the JSON Schema Validation vocabulary
our $VERSION
JSON::Schema::Modern::Utilities qw(is_type get_type is_bignum is_equal is_elements_unique E assert_keyword_type assert_pattern jsonp sprintf_num);
use Math::BigFloat;
use namespace::clean;
with 'JSON
Modern::Vocabulary';
sub vocabulary ($class) {
'https://json-schema.org/draft/2019-09/vocab/validation' => 'draft2019-09',
'https://json-schema.org/draft/2020-12/vocab/validation' => 'draft2020-1
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Base role for JSON Schema vocabulary classes
our $VERSION = '0.623';
use 5.020;
Util 0.100 'is_plain_arrayref';
use JSON::Schema::Modern::Utilities qw(jsonp assert_keyword_type abort);
use Carp ();
use namespace::clean;
our @CARP_NOT = qw(JSON::Schema::Modern);
requires qw(voca
}->_traverse_subschema($schema->{$state->{keyword}}{$property},
+{ %$state, keyword_path => jsonp($state->{keyword_path}, $state->{keyword}, $property) });
}
return $valid;
}
sub traverse_p
use strict;
use warnings;
package JSON::Schema::Modern::Document;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: One JSON Schema document
our $VERSION = '0.623';
use 5.020;
use Moo;
use strictur
:Common::Numeric 'PositiveOrZeroInt';
use JSON::Schema::Modern::Utilities qw(json_pointer_type canonical_uri_type);
use namespace::clean;
extends 'Mojo::JSON::Pointer';
has schema => (
is => 'ro',
be defined in a subclass
);
# "A JSON Schema resource is a schema which is canonically identified by an absolute URI."
# https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.4.3.5
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary::Core;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Implementation of the JSON Schema Core vocabulary
our $VERSION = '0.623';
_plain_hashref';
use JSON::Schema::Modern::Utilities qw(is_type abort assert_keyword_type canonical_uri E assert_uri_reference assert_uri jsonp);
use namespace::clean;
with 'JSON::Schema::Modern::Voc
abulary';
sub vocabulary ($class) {
'https://json-schema.org/draft/2019-09/vocab/core' => 'draft2019-09',
'https://json-schema.org/draft/2020-12/vocab/core' => 'draft2020-12';
}
sub evaluation_o
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary::Content;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Implementation of the JSON Schema Content vocabulary
our $VERSION = '0.
:Try;
use JSON::Schema::Modern::Utilities qw(is_type A assert_keyword_type E abort);
use namespace::clean;
with 'JSON::Schema::Modern::Vocabulary';
sub vocabulary ($class) {
'https://json-schema.o
rg/draft/2019-09/vocab/content' => 'draft2019-09',
'https://json-schema.org/draft/2020-12/vocab/content' => 'draft2020-12';
}
sub evaluation_order ($class) { 4 }
sub keywords ($class, $spec_versio
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary::Applicator;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Implementation of the JSON Schema Applicator vocabulary
our $VERSION
JSON::Schema::Modern::Utilities qw(is_type jsonp E A assert_keyword_type assert_pattern true is_elements_unique);
use JSON::Schema::Modern::Vocabulary::Unevaluated;
use namespace::clean;
with 'JSON:
Modern::Vocabulary';
sub vocabulary ($class) {
'https://json-schema.org/draft/2019-09/vocab/applicator' => 'draft2019-09',
'https://json-schema.org/draft/2020-12/vocab/applicator' => 'draft2020-1
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary::FormatAssertion;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Implementation of the JSON Schema Format-Assertion vocabulary
o
'bareword_filehandles';
no if "$]" >= 5.041009, feature => 'smartmatch';
no feature 'switch';
use JSON::Schema::Modern::Utilities qw(get_type E A assert_keyword_type abort);
use Feature::Compat::Try;
calar::Util 'looks_like_number';
use namespace::clean;
with 'JSON::Schema::Modern::Vocabulary';
sub vocabulary ($class) {
'https://json-schema.org/draft/2020-12/vocab/format-assertion' => 'draft20
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary::MetaData;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Implementation of the JSON Schema Meta-Data vocabulary
our $VERSION =
witch';
use JSON::Schema::Modern::Utilities qw(assert_keyword_type annotate_self);
use namespace::clean;
with 'JSON::Schema::Modern::Vocabulary';
sub vocabulary ($class) {
'https://json-schema.org
/draft/2019-09/vocab/meta-data' => 'draft2019-09',
'https://json-schema.org/draft/2020-12/vocab/meta-data' => 'draft2020-12';
}
sub evaluation_order ($class) { 5 }
sub keywords ($class, $spec_vers
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary::FormatAnnotation;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Implementation of the JSON Schema Format-Annotation vocabulary
rtmatch';
no feature 'switch';
use Feature::Compat::Try;
use JSON::Schema::Modern::Utilities qw(A E assert_keyword_type get_type);
use JSON::Schema::Modern::Vocabulary::FormatAssertion;
use if "$]" <
namespace::clean;
with 'JSON::Schema::Modern::Vocabulary';
sub vocabulary ($class) {
'https://json-schema.org/draft/2019-09/vocab/format' => 'draft2019-09',
'https://json-schema.org/draft/2020-1
use strict;
use warnings;
package JSON::Schema::Modern::Vocabulary::Unevaluated;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Implementation of the JSON Schema Unevaluated vocabulary
our $VERSI
use JSON::Schema::Modern::Utilities qw(is_type jsonp local_annotations E A abort true);
use namespace::clean;
with 'JSON::Schema::Modern::Vocabulary';
sub vocabulary ($class) {
'https://json-sche
ies})) {
next if $schema->{unevaluatedProperties};
$valid = E({ %$state, data_path => jsonp($state->{data_path}, $property) },
'additional property not permitted');
}
else
use strict;
use warnings;
package JSON::Schema::Modern::Result;
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: Contains the result of a JSON Schema evaluation
our $VERSION = '0.623';
use 5.020;
::Common::Numeric 'PositiveInt';
use JSON::Schema::Modern::Annotation;
use JSON::Schema::Modern::Error;
use JSON::Schema::Modern::Utilities qw(true false);
use JSON::PP ();
use List::Util 1.45 'uniq';
id => (
is => 'ro',
isa => Bool|InstanceOf('JSON::PP::true')|InstanceOf('JSON::PP::false'),
coerce => sub { $_[0] ? true : false }, # might be JSON::PP::* or builtin::* booleans
lazy => 1,
d