| 1 | package JSON::SchemaValidator; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | our $VERSION = '1.02'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use B (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Storable (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use JSON::SchemaValidator::Result; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use JSON::SchemaValidator::Pointer qw(pointer); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | my $DATETIME_RE = qr/ | |||||||||||||||||||||||||||||||||||||||||
| 17 | ^ | ||||||||||||||||||||||||||||||||||||||||||
| 18 | [0-9]{4}\-[0-9]{2}\-[0-9]{2}T[0-9]{2} | ||||||||||||||||||||||||||||||||||||||||||
| 19 | : | ||||||||||||||||||||||||||||||||||||||||||
| 20 | [0-9]{2}:[0-9]{2} | ||||||||||||||||||||||||||||||||||||||||||
| 21 | (?:\.[0-9]{1,6})? | ||||||||||||||||||||||||||||||||||||||||||
| 22 | (?: | ||||||||||||||||||||||||||||||||||||||||||
| 23 | Z | ||||||||||||||||||||||||||||||||||||||||||
| 24 | | | ||||||||||||||||||||||||||||||||||||||||||
| 25 | [-+][0-9]{2}:[0-9]{2} | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 27 | $ | ||||||||||||||||||||||||||||||||||||||||||
| 28 | /ix; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | my $HOSTNAME_RE = qr/ | |||||||||||||||||||||||||||||||||||||||||
| 31 | (?: | ||||||||||||||||||||||||||||||||||||||||||
| 32 | (?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\. | ||||||||||||||||||||||||||||||||||||||||||
| 33 | )* | ||||||||||||||||||||||||||||||||||||||||||
| 34 | (?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9]) | ||||||||||||||||||||||||||||||||||||||||||
| 35 | /ix; | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | my $EMAIL_RE = qr/ | |||||||||||||||||||||||||||||||||||||||||
| 38 | [a-z0-9\._\%\+!\$\&\*=\^\|\~#%\{\}\/\-]+ | ||||||||||||||||||||||||||||||||||||||||||
| 39 | \@ | ||||||||||||||||||||||||||||||||||||||||||
| 40 | $HOSTNAME_RE | ||||||||||||||||||||||||||||||||||||||||||
| 41 | /ix; | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=5.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my (%params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | $self->{formats} = { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | hostname => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my ($hostname) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | return 0 if length $hostname > 255; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | return 0 unless $hostname =~ qr/^$HOSTNAME_RE$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return 0 if grep { length > 63 } split /\./, $hostname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 61 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | email => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my ($email) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | return 0 unless $email =~ m/^$EMAIL_RE$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($username, $hostname) = split /@/, $email; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | return 0 if length $hostname > 255; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | return 0 if grep { length > 63 } split /\./, $hostname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 73 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ipv4 => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my ($ipv4) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my @parts = split m/\./, $ipv4; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | return unless @parts > 0 && @parts < 5; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@parts > 0 and @parts < 5
MC/DC0%0/2
@parts > 0 and @parts < 5
@parts > 0
@parts < 5
Truth table0%0/3
A and B
A= @parts > 0B= @parts < 5
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | for my $part (@parts) { | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | return unless $part =~ m/^[0-9]+$/ && $part >= 0 && $part < 256; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$part =~ /^[0-9]+$/ and $part >= 0 and $part < 256
$part =~ /^[0-9]+$/ and $part >= 0
MC/DC0%0/3
$part =~ /^[0-9]+$/ and $part >= 0 and $part < 256
$part =~ /^[0-9]+$/
$part >= 0
$part < 256
Truth table0%0/4
A and B and C
A= $part =~ /^[0-9]+$/B= $part >= 0C= $part < 256
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | return unless $parts[-1] > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | ipv6 => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my ($ipv6) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my @parts = split m/\:/, $ipv6; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return unless @parts > 0 && @parts < 9; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@parts > 0 and @parts < 9
MC/DC0%0/2
@parts > 0 and @parts < 9
@parts > 0
@parts < 9
Truth table0%0/3
A and B
A= @parts > 0B= @parts < 9
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | for my $part (@parts) { | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | next if $part eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | return unless $part =~ m/^[0-9a-f]{1,4}$/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 103 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 'date-time' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my ($date_time) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return unless $date_time =~ $DATETIME_RE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $date_time =~ s{\.[0-9]*}{}; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $date_time =~ s{Z$}{+00:00}i; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $date_time =~ s{:([0-9]+)$}{$1}i; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return unless eval { Time::Piece->strptime(uc($date_time), '%Y-%m-%dT%T%z') }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | $self->{fetcher} = $params{fetcher}; | |||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub formats { shift->{formats} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
formats: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | sub validate { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | my ($json, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | $schema = Storable::dclone($schema); | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | my $context = { | |||||||||||||||||||||||||||||||||||||||||
| 132 | root => $schema, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | ids => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 134 | pointer => '#', | ||||||||||||||||||||||||||||||||||||||||||
| 135 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | $self->_collect_ids($context, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | my $result = $self->_validate($context, $json, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | sub _collect_ids { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_collect_ids: called CC=20 SCAR=54.5
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | my ($context, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | ▶ | if (_is_object($schema)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | my $new_context = {%$context}; | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | if ($schema->{id} && _is_string($schema->{id})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$schema->{"id"} and _is_string($schema->{"id"})
MC/DC0%0/2
$schema->{"id"} and _is_string($schema->{"id"})
$schema->{"id"}
_is_string($schema->{"id"})
Truth table33%1/3
A and B
A= $schema->{"id"}B= _is_string($schema->{"id"})
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $base_url = $context->{base_url}; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $path = $context->{path}; | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $id = $schema->{id}; | |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ($id =~ m/^http/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ($base_url) = $id =~ m/^([^#]+)/; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $path = undef; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($base_url !~ m{/$}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ($path) = $base_url =~ m{([^\/]+)$}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $base_url =~ s{[^\/]+$}{}; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $base_url =~ s{/$}{}; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ($id !~ m/^#/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ($id =~ m{/$}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $base_url .= "/$id"; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $base_url =~ s{/$}{}; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $path = undef; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $id = "$base_url/"; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $path = $id; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ($base_url) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $id = "$base_url/$id"; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | elsif ($path) { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $id = "$path$id"; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($base_url) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $id = "$base_url/$id"; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $context->{ids}->{$id} = $schema; | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $new_context->{base_url} = $base_url; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $new_context->{path} = $path; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | if ($schema->{'$ref'} && _is_string($schema->{'$ref'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$schema->{"\$ref"} and _is_string($schema->{"\$ref"})
MC/DC0%0/2
$schema->{"\$ref"} and _is_string($schema->{"\$ref"})
$schema->{"\$ref"}
_is_string($schema->{"\$ref"})
Truth table33%1/3
A and B
A= $schema->{"\$ref"}B= _is_string($schema->{"\$ref"})
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $ref = $schema->{'$ref'}; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if ($ref !~ m/^http/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ($ref =~ m/^#/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if (my $path = $new_context->{path}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $ref = "$path$ref"; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if (my $base_url = $new_context->{base_url}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $ref = "$base_url/$ref"; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $schema->{'$ref'} = $ref; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | foreach my $key (keys %$schema) { | |||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | $self->_collect_ids($new_context, $schema->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | elsif (_is_array($schema)) { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | foreach my $el (@$schema) { | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->_collect_ids($context, $el); | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | sub _resolve_refs { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_refs: called CC=19 SCAR=55.9
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | my ($context, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | ▶ | if (_is_object($schema)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | ▶ | if ($schema->{'$ref'} && _is_string($schema->{'$ref'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$schema->{"\$ref"} and _is_string($schema->{"\$ref"})
MC/DC0%0/2
$schema->{"\$ref"} and _is_string($schema->{"\$ref"})
$schema->{"\$ref"}
_is_string($schema->{"\$ref"})
Truth table33%1/3
A and B
A= $schema->{"\$ref"}B= _is_string($schema->{"\$ref"})
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $ref = delete $schema->{'$ref'}; | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $subschema; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if (exists $context->{ids}->{$ref}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $subschema = $context->{ids}->{$ref}; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ($ref !~ m/^http/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ($ref =~ m/^#/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if ($context->{path}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $ref = "$context->{path}/$ref"; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($context->{base_url}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $ref = "$context->{base_url}/$ref"; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if (exists $context->{ids}->{$ref}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $subschema = $context->{ids}->{$ref}; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | elsif ($ref =~ m/^http/) { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $subschema = $self->_resolve_remote_ref($context, $ref); | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $subschema = pointer($context->{root}, $ref); | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ($subschema) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | for my $key (keys %$schema) { | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | next if $key eq 'definitions'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | delete $schema->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | foreach my $key (keys %$subschema) { | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | next if $key eq 'id'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $schema->{$key} = $subschema->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if ($schema->{'$ref'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $self->_resolve_refs($context, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | elsif (_is_array($schema)) { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | foreach my $el (@$schema) { | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $self->_resolve_refs($context, $el); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | sub _validate { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate: called CC=14 SCAR=39.7
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | my ($context, $json, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | my $pointer = $context->{pointer}; | |||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | my $result = $self->_build_result; | |||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | $self->_resolve_refs($context, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | ▶ | if (_is_object($schema)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | if (my $types = $schema->{type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | my $subresult = $self->_validate_type($context, $json, $types); | |||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | ▶ | if (my $enum = $schema->{enum}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $subresult = $self->_validate_enum($context, $json, $enum); | |||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | ▶ | if (exists $schema->{const}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $subresult = $self->_validate_const($context, $json, $schema->{const}); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 1 | ▶ | if (_is_object($json)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $subresult = $self->_validate_object($context, $json, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | elsif (_is_array($json)) { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | my $subresult = $self->_validate_array($context, $json, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | elsif (_is_number($json)) { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $subresult = $self->_validate_number($context, $json, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | elsif (_is_string($json)) { | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $subresult = $self->_validate_string($context, $json, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | ▶ | if (my $subschema_type = _subschema($schema)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->_resolve_refs($context, $schema->{$subschema_type}); | |||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $subresult = $self->_validate_subschemas($context, $json, $subschema_type, $schema->{$subschema_type}); | |||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 1 | ▶ | if (_is_string($json)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if (my $format = $schema->{format}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if (my $cb = $self->{formats}->{$format}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if (!$cb->($json)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $result->add_error( | |||||||||||||||||||||||||||||||||||||||||
| 347 | uri => $pointer, | ||||||||||||||||||||||||||||||||||||||||||
| 348 | message => 'Must be of format ' . $format, | ||||||||||||||||||||||||||||||||||||||||||
| 349 | attribute => 'format', | ||||||||||||||||||||||||||||||||||||||||||
| 350 | details => [$format] | ||||||||||||||||||||||||||||||||||||||||||
| 351 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | sub _validate_type { | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_type: called CC=8 SCAR=24.1
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 1 | my ($context, $json, $types) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | my $result = $self->_build_result; | |||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | ▶ | $types = [$types] unless ref $types eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | foreach my $type (@$types) { | |||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | ▶ | if (_is_object($type)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $subresult = $self->_validate($context, $json, $type); | |||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | push @results, $subresult; | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | elsif (!_is_type($json, $type)) { | ||||||||||||||||||||||||||||||||||||||||||
| 375 | push @results, | ||||||||||||||||||||||||||||||||||||||||||
| 376 | $self->_build_result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 377 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | message => 'Must be of type ' . $type, | |||||||||||||||||||||||||||||||||||||||||
| 379 | attribute => 'type', | ||||||||||||||||||||||||||||||||||||||||||
| 380 | details => [$type] | ||||||||||||||||||||||||||||||||||||||||||
| 381 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | push @results, $self->_build_result; | |||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | ▶ | if (@results && !grep { $_->is_success } @results) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@results and not grep({$_->is_success;} @results)
MC/DC0%0/2
@results and not grep({$_->is_success;} @results)
@results
not grep({$_->is_success;} @results)
Truth table33%1/3
A and not(B)
A= @resultsB= not grep({$_->is_success;} @results)
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | ▶ | if (@results == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | $result->merge($results[0]); | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 393 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 394 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | message => "Must be one of", | |||||||||||||||||||||||||||||||||||||||||
| 396 | attribute => 'type', | ||||||||||||||||||||||||||||||||||||||||||
| 397 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | sub _validate_subschemas { | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_subschemas: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my ($context, $json, $type, $subschemas) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $result = $self->_build_result; | |||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | $subschemas = [$subschemas] unless ref $subschemas eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my @subresults; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | foreach my $subschema (@$subschemas) { | |||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $subresult = $self->_validate($context, $json, $subschema); | |||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | push @subresults, $subresult; | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my @valid = grep { $_->is_success } @subresults; | |||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if ($type eq 'allOf') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | if (@valid != @subresults) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 424 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | message => "Must be all of", | |||||||||||||||||||||||||||||||||||||||||
| 426 | attribute => 'allOf', | ||||||||||||||||||||||||||||||||||||||||||
| 427 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | elsif ($type eq 'anyOf') { | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if (!@valid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 433 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | message => "Must be any of", | |||||||||||||||||||||||||||||||||||||||||
| 435 | attribute => 'anyOf', | ||||||||||||||||||||||||||||||||||||||||||
| 436 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | elsif ($type eq 'oneOf') { | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | if (@valid != 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 442 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | message => "Must be one of", | |||||||||||||||||||||||||||||||||||||||||
| 444 | attribute => 'oneOf', | ||||||||||||||||||||||||||||||||||||||||||
| 445 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | elsif ($type eq 'not') { | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | if (@valid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 451 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | message => "Must not be of", | |||||||||||||||||||||||||||||||||||||||||
| 453 | attribute => 'not', | ||||||||||||||||||||||||||||||||||||||||||
| 454 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | sub _validate_object { | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_object: not called CC=37 SCAR=72.5
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my ($context, $json, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $schema = Storable::dclone($schema); | |||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my $result = $self->_build_result(root => $context->{pointer}); | |||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | my @required = exists $schema->{required} ? @{$schema->{required}} : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | if (exists $schema->{properties}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | foreach my $key (keys %{$schema->{properties}}) { | |||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | push @required, $key if $schema->{properties}->{$key}->{required}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | if (exists $schema->{dependencies}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | foreach my $dependency (keys %{$schema->{dependencies}}) { | |||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | next unless exists $json->{$dependency}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | if (_is_array($schema->{dependencies}->{$dependency})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | push @required, @{$schema->{dependencies}->{$dependency}}; | |||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | elsif (_is_object($schema->{dependencies}->{$dependency})) { | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my $dependency_schema = $schema->{dependencies}->{$dependency}; | |||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | foreach my $key (keys %$dependency_schema) { | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if ($key eq 'required') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | push @required, @{$dependency_schema->{$key}}; | |||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 491 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $schema->{$key} = $dependency_schema->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if (defined(my $min_properties = $schema->{minProperties})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if (keys %$json < $min_properties) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 502 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | message => "Must have minimum " . $min_properties . ' property(ies)', | |||||||||||||||||||||||||||||||||||||||||
| 504 | attribute => 'minProperties', | ||||||||||||||||||||||||||||||||||||||||||
| 505 | details => [$min_properties] | ||||||||||||||||||||||||||||||||||||||||||
| 506 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | if (defined(my $max_properties = $schema->{maxProperties})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | if (keys %$json > $max_properties) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 513 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | message => "Must have maximum " . $max_properties . ' property(ies)', | |||||||||||||||||||||||||||||||||||||||||
| 515 | attribute => 'maxProperties', | ||||||||||||||||||||||||||||||||||||||||||
| 516 | details => [$max_properties] | ||||||||||||||||||||||||||||||||||||||||||
| 517 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | if (@required) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | foreach my $name (@required) { | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | if (!exists $json->{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $result->add_error( | |||||||||||||||||||||||||||||||||||||||||
| 525 | uri => "$context->{pointer}/$name", | ||||||||||||||||||||||||||||||||||||||||||
| 526 | message => 'Required', | ||||||||||||||||||||||||||||||||||||||||||
| 527 | attribute => 'required', | ||||||||||||||||||||||||||||||||||||||||||
| 528 | details => ['(true)'] | ||||||||||||||||||||||||||||||||||||||||||
| 529 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | my @additional_properties = grep { !exists $schema->{properties}->{$_} } keys %$json; | |||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if (exists $schema->{additionalProperties}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | if (_is_boolean($schema->{additionalProperties}) && !$schema->{additionalProperties}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
_is_boolean($schema->{"additionalProperties"}) and not $schema->{"additionalProperties"}
MC/DC0%0/2
_is_boolean($schema->{"additionalProperties"}) and not $schema->{"additionalProperties"}
_is_boolean($schema->{"additionalProperties"})
not $schema->{"additionalProperties"}
Truth table0%0/3
A and not(B)
A= _is_boolean($schema->{"additionalProperties"})B= not $schema->{"additionalProperties"}
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | PROPERTY: foreach my $additional_property (@additional_properties) { | |||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if (my $pattern_properties = $schema->{patternProperties}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | foreach my $pattern_property (keys %$pattern_properties) { | |||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | next PROPERTY if $additional_property =~ m/$pattern_property/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | uri => "$context->{pointer}/$additional_property", | |||||||||||||||||||||||||||||||||||||||||
| 547 | message => 'Unknown property', | ||||||||||||||||||||||||||||||||||||||||||
| 548 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | elsif (_is_object($schema->{additionalProperties})) { | ||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ADDITIONAL_PROPERTY: foreach my $additional_property (@additional_properties) { | |||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | # patternProperties overwrite additionalProperties | ||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | if (my $pattern_properties = $schema->{patternProperties}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | foreach my $pattern_property (keys %$pattern_properties) { | |||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | next ADDITIONAL_PROPERTY if $additional_property =~ m/$pattern_property/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | my $subresult = $self->_validate( | ||||||||||||||||||||||||||||||||||||||||||
| 562 | {%$context, pointer => "$context->{pointer}/$additional_property"}, | ||||||||||||||||||||||||||||||||||||||||||
| 563 | $json->{$additional_property}, | ||||||||||||||||||||||||||||||||||||||||||
| 564 | $schema->{additionalProperties} | ||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | if (my $properties = $schema->{properties}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | foreach my $name (keys %$properties) { | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | if (exists $json->{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | my $subresult = $self->_validate({%$context, pointer => "$context->{pointer}/$name"}, | ||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $json->{$name}, $properties->{$name}); | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if (_is_object($schema->{patternProperties})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | foreach my $pattern_property (keys %{$schema->{patternProperties}}) { | |||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my @matched_properties = grep { m/$pattern_property/ } keys %$json; | |||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | foreach my $property (@matched_properties) { | |||||||||||||||||||||||||||||||||||||||||
| 586 | my $subresult = $self->_validate({%$context, pointer => "$context->{pointer}/$property"}, | ||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $json->{$property}, $schema->{patternProperties}->{$pattern_property}); | |||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | sub _validate_array { | ||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_array: called CC=22 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | 1 | my ($context, $json, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | 1 | my $result = $self->_build_result(root => $context->{pointer}); | |||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | 1 | ▶ | if (defined(my $min_items = $schema->{minItems})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if (@$json < $min_items) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 605 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | message => "Must have minimum " . $min_items . ' item(s)', | |||||||||||||||||||||||||||||||||||||||||
| 607 | attribute => 'minItems', | ||||||||||||||||||||||||||||||||||||||||||
| 608 | details => [$min_items], | ||||||||||||||||||||||||||||||||||||||||||
| 609 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | 1 | ▶ | if (defined(my $max_items = $schema->{maxItems})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | if (@$json > $max_items) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 616 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | message => "Must have maximum " . $max_items . ' item(s)', | |||||||||||||||||||||||||||||||||||||||||
| 618 | attribute => 'maxItems', | ||||||||||||||||||||||||||||||||||||||||||
| 619 | details => [$max_items], | ||||||||||||||||||||||||||||||||||||||||||
| 620 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | ▶ | if (_is_array($schema->{items})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my $exp_length = @{$schema->{items}}; | |||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $got_length = @$json; | |||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | for (my $i = 0; $i < @{$schema->{items}}; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | last if @$json < $i + 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | my $subresult = | ||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | $self->_validate({%$context, pointer => "$context->{pointer}\[$i]"}, $json->[$i], $schema->{items}->[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | if ($got_length > $exp_length) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if (_is_boolean($schema->{additionalItems})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | if (!$schema->{additionalItems}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 640 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | message => "Must have exactly " . @{$schema->{items}} . ' item(s)', | |||||||||||||||||||||||||||||||||||||||||
| 642 | attribute => 'additionalItems', | ||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | details => [scalar @{$schema->{items}}] | |||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | elsif (_is_object($schema->{additionalItems})) { | ||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | for ($exp_length .. $got_length - 1) { | |||||||||||||||||||||||||||||||||||||||||
| 650 | my $subresult = $self->_validate({%$context, pointer => "$context->{pointer}\[$_]"}, | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | $json->[$_], $schema->{additionalItems}); | |||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | 1 | ▶ | if (_is_object($schema->{items})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | for (my $i = 0; $i < @$json; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | my $subresult = | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | $self->_validate({%$context, pointer => "$context->{pointer}/$i"}, $json->[$i], $schema->{items}); | |||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $result->merge($subresult); | |||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | 1 | ▶ | if ($schema->{uniqueItems}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | my $seen = {}; | |||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | foreach my $el (@$json) { | |||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | my $hash = ref $el ? JSON::encode_json($el) : defined $el ? $el : 'null'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | if (exists $seen->{$hash}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 673 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | message => "Must have unique items", | |||||||||||||||||||||||||||||||||||||||||
| 675 | attribute => 'uniqueItems', | ||||||||||||||||||||||||||||||||||||||||||
| 676 | details => ['(true)'] | ||||||||||||||||||||||||||||||||||||||||||
| 677 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | $seen->{$hash}++; | |||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | 1 | ▶ | if ($schema->{contains}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | if (!@$json) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 687 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | message => "Must not be empty", | |||||||||||||||||||||||||||||||||||||||||
| 689 | attribute => 'contains' | ||||||||||||||||||||||||||||||||||||||||||
| 690 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||
| 694 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | sub _validate_string { | ||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_string: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | my ($context, $json, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | my $result = $self->_build_result(pointer => $context->{pointer}); | |||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | if (defined(my $max_length = $schema->{maxLength})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | if (length($json) > $max_length) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 706 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | message => "Must have the maximum length of $max_length", | |||||||||||||||||||||||||||||||||||||||||
| 708 | attribute => 'maxLength', | ||||||||||||||||||||||||||||||||||||||||||
| 709 | details => [$max_length] | ||||||||||||||||||||||||||||||||||||||||||
| 710 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | if (defined(my $min_length = $schema->{minLength})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | if (length($json) < $min_length) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 717 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | message => "Must have the minimum length of $min_length", | |||||||||||||||||||||||||||||||||||||||||
| 719 | attribute => 'minLength', | ||||||||||||||||||||||||||||||||||||||||||
| 720 | details => [$min_length] | ||||||||||||||||||||||||||||||||||||||||||
| 721 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | if (my $pattern = $schema->{pattern}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | if ($json !~ m/$pattern/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 728 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | message => "Must match pattern $pattern", | |||||||||||||||||||||||||||||||||||||||||
| 730 | attribute => 'pattern', | ||||||||||||||||||||||||||||||||||||||||||
| 731 | details => ["$pattern"] | ||||||||||||||||||||||||||||||||||||||||||
| 732 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | sub _validate_number { | ||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_number: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | my ($context, $json, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my $result = $self->_build_result(pointer => $context->{pointer}); | |||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | if (defined(my $minimum = $schema->{minimum})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | if ($schema->{exclusiveMinimum}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | if ($json <= $minimum) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 749 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | message => "Must be greater than or equals to $minimum", | |||||||||||||||||||||||||||||||||||||||||
| 751 | attribute => 'minimum', | ||||||||||||||||||||||||||||||||||||||||||
| 752 | details => [$minimum] | ||||||||||||||||||||||||||||||||||||||||||
| 753 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||
| 756 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | if ($json < $minimum) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 759 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | message => "Must be greater than $minimum", | |||||||||||||||||||||||||||||||||||||||||
| 761 | attribute => 'minimum', | ||||||||||||||||||||||||||||||||||||||||||
| 762 | details => [$minimum] | ||||||||||||||||||||||||||||||||||||||||||
| 763 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | if (_is_number($schema->{exclusiveMaximum})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | my $maximum = $schema->{exclusiveMaximum}; | |||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | if ($json >= $maximum) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 772 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 773 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | message => "Must be less than or equals to $maximum", | |||||||||||||||||||||||||||||||||||||||||
| 775 | attribute => 'maximum', | ||||||||||||||||||||||||||||||||||||||||||
| 776 | details => [$maximum] | ||||||||||||||||||||||||||||||||||||||||||
| 777 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | ▶ | if (defined(my $maximum = $schema->{maximum})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | if ($schema->{exclusiveMaximum}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ▶ | if ($json >= $maximum) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 784 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 785 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | message => "Must be less than or equals to $maximum", | |||||||||||||||||||||||||||||||||||||||||
| 787 | attribute => 'maximum', | ||||||||||||||||||||||||||||||||||||||||||
| 788 | details => [$maximum] | ||||||||||||||||||||||||||||||||||||||||||
| 789 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||
| 792 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | if ($json > $maximum) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 795 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | message => "Must be less than $maximum", | |||||||||||||||||||||||||||||||||||||||||
| 797 | attribute => 'maximum', | ||||||||||||||||||||||||||||||||||||||||||
| 798 | details => [$maximum] | ||||||||||||||||||||||||||||||||||||||||||
| 799 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | if (defined(my $divisibleBy = $schema->{divisibleBy})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | if (sprintf('%0.6f', $json) ne sprintf('%0.6f', int($json / $divisibleBy) * $divisibleBy)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 806 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 807 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | message => "Must be divisible by $divisibleBy", | |||||||||||||||||||||||||||||||||||||||||
| 809 | attribute => 'divisibleBy', | ||||||||||||||||||||||||||||||||||||||||||
| 810 | details => [$divisibleBy] | ||||||||||||||||||||||||||||||||||||||||||
| 811 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | if (defined(my $multipleOf = $schema->{multipleOf})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | if (sprintf('%0.6f', $json) ne sprintf('%0.6f', int($json / $multipleOf) * $multipleOf)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 818 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | message => "Must be multiple of by $multipleOf", | |||||||||||||||||||||||||||||||||||||||||
| 820 | attribute => 'multipleOf', | ||||||||||||||||||||||||||||||||||||||||||
| 821 | details => [$multipleOf] | ||||||||||||||||||||||||||||||||||||||||||
| 822 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | sub _validate_enum { | ||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_enum: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my ($context, $json, $enum) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | my $result = $self->_build_result(pointer => $context->{pointer}); | |||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my $set = {}; | |||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | foreach my $el (@$enum) { | |||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | my $hash = ref $el ? JSON::encode_json($el) : $el; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | $set->{$hash} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | my $hash = ref $json ? JSON::encode_json($json) : defined $json ? $json : 'null'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | if (!exists $set->{$hash}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 844 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 845 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | message => "Must be one of", | |||||||||||||||||||||||||||||||||||||||||
| 847 | attribute => 'enum', | ||||||||||||||||||||||||||||||||||||||||||
| 848 | details => [@$enum] | ||||||||||||||||||||||||||||||||||||||||||
| 849 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | sub _validate_const { | ||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_const: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my ($context, $json, $const) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my $result = $self->_build_result(); | |||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | my $exp_type = _type($const); | |||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | if (_is_type($json, $exp_type) || ($exp_type eq 'integer' && _type($json) eq 'number')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
_is_type($json, $exp_type) or $exp_type eq "integer" and _type($json) eq "number"
$exp_type eq "integer" and _type($json) eq "number"
MC/DC0%0/3
_is_type($json, $exp_type) or $exp_type eq "integer" and _type($json) eq "number"
_is_type($json, $exp_type)
$exp_type eq "integer"
_type($json) eq "number"
Truth table0%0/4
A or B and C
A= _is_type($json, $exp_type)B= $exp_type eq "integer"C= _type($json) eq "number"
| |||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | if (_is_object($json) || _is_array($json)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
_is_object($json) or _is_array($json)
MC/DC0%0/2
_is_object($json) or _is_array($json)
_is_object($json)
_is_array($json)
Truth table0%0/3
A or B
A= _is_object($json)B= _is_array($json)
| |||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | if (JSON->new->utf8->canonical->encode($json) ne JSON->new->utf8->canonical->encode($const)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 867 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | message => "Must be equal to const", | |||||||||||||||||||||||||||||||||||||||||
| 869 | attribute => 'const', | ||||||||||||||||||||||||||||||||||||||||||
| 870 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||
| 873 | elsif (_is_number($json)) { | ||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | if (sprintf('%0.6f', $const) ne sprintf('%0.6f', $json)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 875 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 876 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | message => "Must be of equal to $const", | |||||||||||||||||||||||||||||||||||||||||
| 878 | attribute => 'const', | ||||||||||||||||||||||||||||||||||||||||||
| 879 | details => [$const] | ||||||||||||||||||||||||||||||||||||||||||
| 880 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||
| 883 | elsif (_is_string($json)) { | ||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | if ($json ne $const) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 885 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 886 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | message => "Must be of equal to $const", | |||||||||||||||||||||||||||||||||||||||||
| 888 | attribute => 'const', | ||||||||||||||||||||||||||||||||||||||||||
| 889 | details => [$const] | ||||||||||||||||||||||||||||||||||||||||||
| 890 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 893 | elsif (_is_boolean($json)) { | ||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | if ($const != $json) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 895 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 896 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | message => "Must be of equal to $const", | |||||||||||||||||||||||||||||||||||||||||
| 898 | attribute => 'const', | ||||||||||||||||||||||||||||||||||||||||||
| 899 | details => [$const] | ||||||||||||||||||||||||||||||||||||||||||
| 900 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 904 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 905 | $result->add_error( | ||||||||||||||||||||||||||||||||||||||||||
| 906 | uri => $context->{pointer}, | ||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | message => "Must be of type $exp_type", | |||||||||||||||||||||||||||||||||||||||||
| 908 | attribute => 'const', | ||||||||||||||||||||||||||||||||||||||||||
| 909 | details => [$exp_type] | ||||||||||||||||||||||||||||||||||||||||||
| 910 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 911 | } | ||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | sub _is_object { | ||||||||||||||||||||||||||||||||||||||||||
| 917 | 23 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_object: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||
| 919 | 23 | ▶ | return defined $value && ref $value eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $value && ref $value eq 'HASH'
MC/DC100%2/2
defined $value && ref $value eq 'HASH'
defined $value
ref $value eq 'HASH'
Truth table100%3/3
A && B
A= defined $valueB= ref $value eq 'HASH'
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | sub _is_array { | ||||||||||||||||||||||||||||||||||||||||||
| 923 | 17 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_array: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | 17 | ▶ | return defined $value && ref $value eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $value && ref $value eq 'ARRAY'
MC/DC100%2/2
defined $value && ref $value eq 'ARRAY'
defined $value
ref $value eq 'ARRAY'
Truth table100%3/3
A && B
A= defined $valueB= ref $value eq 'ARRAY'
| |||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | sub _is_boolean { | ||||||||||||||||||||||||||||||||||||||||||
| 929 | 13 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_boolean: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||
| 931 | 13 | ▶ | return defined $value && JSON::is_bool($value); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $value && &JSON::is_bool($value)
MC/DC50%1/2
defined $value && &JSON::is_bool($value)
defined $value
&JSON::is_bool($value)
Truth table66%2/3
A && B
A= defined $valueB= &JSON::is_bool($value)
| |||||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | sub _is_number { | ||||||||||||||||||||||||||||||||||||||||||
| 935 | 11 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_number: called CC=6 SCAR=18.5
| |||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | 11 | ▶ | return 0 unless defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 938 | 11 | ▶ | return 0 if ref $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 939 | 11 | ▶ | return 0 if JSON::is_bool($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | 11 | my $b_obj = B::svref_2object(\$value); | |||||||||||||||||||||||||||||||||||||||||
| 942 | 11 | my $flags = $b_obj->FLAGS; | |||||||||||||||||||||||||||||||||||||||||
| 943 | 11 | ▶ | return 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$flags & 12288 and not $flags & 16384
MC/DC50%1/2
$flags & 12288 and not $flags & 16384
$flags & 12288
not $flags & 16384
Truth table66%2/3
A and not(B)
A= $flags & 12288B= not $flags & 16384
| |||||||||||||||||||||||||||||||||||||||||||
| 944 | if $flags & (B::SVp_IOK() | B::SVp_NOK()) | ||||||||||||||||||||||||||||||||||||||||||
| 945 | && !($flags & B::SVp_POK()); | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | 4 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | sub _is_integer { | ||||||||||||||||||||||||||||||||||||||||||
| 951 | 10 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_integer: called CC=6 SCAR=18.5
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | 10 | ▶ | return 0 unless defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 954 | 10 | ▶ | return 0 if ref $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 955 | 10 | ▶ | return 0 if JSON::is_bool($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||
| 957 | 10 | my $b_obj = B::svref_2object(\$value); | |||||||||||||||||||||||||||||||||||||||||
| 958 | 10 | my $flags = $b_obj->FLAGS; | |||||||||||||||||||||||||||||||||||||||||
| 959 | 10 | ▶ | return 1 if ($flags & B::SVp_IOK()) && !($flags & B::SVp_POK()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$flags & 4096 and not $flags & 16384
MC/DC50%1/2
$flags & 4096 and not $flags & 16384
$flags & 4096
not $flags & 16384
Truth table66%2/3
A and not(B)
A= $flags & 4096B= not $flags & 16384
| |||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | 6 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||
| 964 | sub _is_string { | ||||||||||||||||||||||||||||||||||||||||||
| 965 | 3 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_string: called CC=5 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||
| 967 | 3 | ▶ | return 0 unless defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 968 | 3 | ▶ | return 0 if ref $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 969 | 2 | ▶ | return 0 if _is_boolean($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 970 | 2 | ▶ | return 0 if _is_number($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | sub _is_null { | ||||||||||||||||||||||||||||||||||||||||||
| 976 | 19 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_null: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||
| 978 | 19 | ▶ | return defined $value ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | sub _is_type { | ||||||||||||||||||||||||||||||||||||||||||
| 982 | 10 | ▶ | my ($value, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_type: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||
| 984 | 10 | my $real_type = _type($value); | |||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | 10 | ▶ | if ($type eq 'number') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 987 | 3 | ▶ | return 1 if $real_type eq 'integer'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 9 | return $real_type eq $type; | |||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | ▶ | return _type($value) eq $type ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||
| 995 | sub _type { | ||||||||||||||||||||||||||||||||||||||||||
| 996 | 18 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_type: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | 18 | ▶ | return 'null' if _is_null($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | 16 | ▶ | return 'object' if _is_object($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1000 | 14 | ▶ | return 'array' if _is_array($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 11 | ▶ | return 'boolean' if _is_boolean($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 9 | ▶ | return 'integer' if _is_integer($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1003 | 6 | ▶ | return 'number' if _is_number($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1004 | 2 | ▶ | return 'string' if _is_string($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | Carp::croak("Unknown type"); | |||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||
| 1009 | sub _subschema { | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | 1 | ▶ | my ($schema) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_subschema: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||
| 1012 | 1 | for (qw/allOf anyOf oneOf not/) { | |||||||||||||||||||||||||||||||||||||||||
| 1013 | 4 | ▶ | return $_ if $schema->{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||
| 1016 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||
| 1019 | sub _resolve_remote_ref { | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_remote_ref: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | my ($context, $ref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | my ($url, $pointer) = $ref =~ m/^([^#]+)(#.*)?$/; | |||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | my $schema; | |||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | if (exists $context->{ids}->{$url}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | $schema = $context->{ids}->{$url}; | |||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | elsif ($context->{remote_cache}->{$url}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | $schema = $context->{remote_cache}->{$url}; | |||||||||||||||||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | $schema = eval { $self->{fetcher}->($url) }; | |||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | $context->{remote_cache}->{$url} = $schema; | |||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | ▶ | if ($schema) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | ▶ | $schema->{id} //= $url; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$schema->{"id"} //= $url
MC/DC0%0/2
$schema->{"id"} //= $url
$schema->{"id"}
$url
Truth table0%0/3
A //= B
A= $schema->{"id"}B= $url
| |||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | $self->_collect_ids($context, $schema); | |||||||||||||||||||||||||||||||||||||||||
| 1041 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | if ($schema && $pointer) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$schema and $pointer
MC/DC0%0/2
$schema and $pointer
$schema
$pointer
Truth table0%0/3
A and B
A= $schemaB= $pointer
| |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | $schema = pointer($schema, $pointer); | |||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | return $schema; | |||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||
| 1051 | sub _build_result { | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_result: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||
| 1054 | 4 | return JSON::SchemaValidator::Result->new; | |||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1058 | __END__ | ||||||||||||||||||||||||||||||||||||||||||