package JSON::SchemaValidator;
use strict;
use warnings;
our $VERSION = '1.04';
use B ();
use Storable ();
require Carp;
use Time::Piece;
use JSON::SchemaValidator::Result;
use JSON::Schema
return $self;
}
sub formats { shift->{formats} }
sub validate {
my $self = shift;
my ($json, $schema) = @_;
$schema = Storable::dclone($schema);
my $context = {
root =>
};
$self->_collect_ids($context, $schema);
my $result = $self->_validate($context, $json, $schema);
return $result;
}
sub _collect_ids {
my $self = shift;
my ($context, $sc
package JSON::SchemaValidator::Pointer;
use strict;
use warnings;
use base 'Exporter';
our @EXPORT_OK = qw(pointer);
use URI::Escape qw(uri_unescape);
sub pointer {
my ($json, $pointer) = @_;
ter =~ m/^#/;
$pointer = uri_unescape($pointer);
$pointer =~ s{^#/?}{};
my $top = $json;
foreach my $part (split m{/}, $pointer) {
$part =~ s{\~1}{\/}g;
$part =~ s{\
package JSON::SchemaValidator::Result;
use strict;
use warnings;
use JSON;
sub new {
my $class = shift;
my (%params) = @_;
my $self = {};
bless $self, $class;
$self->{errors}
ors {
my $self = shift;
return $self->{errors};
}
sub errors_json {
my $self = shift;
return JSON::encode_json($self->{errors});
}
sub add_error {
my $self = shift;
if (@_