Branch Coverage

blib/lib/JSON/Schema/Modern/Vocabulary/Validation.pm
Criterion Covered Total %
branch 142 166 85.5


line true false branch
37 73 19 $spec_version ne 'draft7' ? :
73 19 $spec_version ne 'draft7' ? :
48 279 5742 if (XXX) { }
49 0 279 unless @{$schema->{'type'}}
52 2 574 unless &any(sub {
54 0 277 unless is_elements_unique($schema->{'type'})
57 2 5740 unless assert_keyword_type($state, $schema, "string")
59 4 5736 unless &any(sub {
66 1522 5484 if (XXX) { }
71 289 0 unless $type eq $_ or $_ eq "number" and $type eq "integer" or $type eq "string" and $state->{'stringy_numbers'} and &looks_like_number($data) and $_ eq 'number' || $_ eq 'integer' && $data == int $data
72 1409 113 if &any(sub {
79 2 121 if $type eq $schema->{'type'} or $schema->{'type'} eq "number" and $type eq "integer" or $type eq "string" and $state->{'stringy_numbers'} and &looks_like_number($data) and $schema->{'type'} eq 'number' || $schema->{'type'} eq 'integer' && $data == int $data or $schema->{'type'} eq "boolean" and $state->{'scalarref_booleans'} and $type eq "reference to SCALAR"
85 0 499 unless assert_keyword_type($state, $schema, "array")
92 268 188 if &any(sub {
95 181 7 !grep($_->{'path'}, @s) ? :
102 597 530 if is_equal($data, $schema->{'const'}, my $s = {"scalarref_booleans", $state->{'scalarref_booleans'}})
104 55 475 $s->{'path'} ? :
108 2 901 unless assert_keyword_type($state, $schema, "number")
109 0 901 if $schema->{'multipleOf'} <= 0
116 0 2 unless is_type("number", $data) or $state->{'stringy_numbers'} and is_type("string", $data) and &looks_like_number($data) and do {
119 52 648 if (ref($data) =~ /^Math::Big(?:Int|Float)$/u or ref($schema->{'multipleOf'}) =~ /^Math::Big(?:Int|Float)$/u or get_type($data) eq 'number' or get_type($schema->{'multipleOf'}) eq 'number') { }
122 30 22 ref($data) =~ /^Math::Big(?:Int|Float)$/u ? :
123 48 4 ref($schema->{'multipleOf'}) =~ /^Math::Big(?:Int|Float)$/u ? :
125 0 52 if $quotient->is_inf
126 30 22 if $remainder == 0
130 648 0 "$]" >= 5.022 ? :
0 648 if "$]" >= "5.022" ? isinf($quotient) : $quotient =~ /^-?Inf$/iu
132 344 304 if int $quotient == $quotient
142 0 1 unless is_type("number", $data) or $state->{'stringy_numbers'} and is_type("string", $data) and &looks_like_number($data)
143 266 214 if 0 + $data <= $schema->{'maximum'}
151 0 1 unless is_type("number", $data) or $state->{'stringy_numbers'} and is_type("string", $data) and &looks_like_number($data)
152 146 163 if 0 + $data < $schema->{'exclusiveMaximum'}
160 0 1 unless is_type("number", $data) or $state->{'stringy_numbers'} and is_type("string", $data) and &looks_like_number($data)
161 281 266 if 0 + $data >= $schema->{'minimum'}
169 0 1 unless is_type("number", $data) or $state->{'stringy_numbers'} and is_type("string", $data) and &looks_like_number($data)
170 116 132 if 0 + $data > $schema->{'exclusiveMinimum'}
177 225 360 unless is_type("string", $data)
178 190 170 if length $data <= $schema->{'maxLength'}
186 226 327 unless is_type("string", $data)
187 173 154 if length $data >= $schema->{'minLength'}
193 1 985 unless assert_keyword_type($state, $schema, "string") and assert_pattern($state, $schema->{'pattern'})
198 243 785 unless is_type("string", $data)
200 416 368 if $data =~ /(?:$schema->{'pattern'})/u
207 177 264 unless is_type("array", $data)
208 138 126 if @$data <= $schema->{'maxItems'}
209 22 104 $schema->{'maxItems'} > 1 ? :
215 218 274 unless is_type("array", $data)
216 146 128 if @$data >= $schema->{'minItems'}
217 116 12 $schema->{'minItems'} > 1 ? :
221 0 862 unless assert_keyword_type($state, $schema, "boolean")
226 212 625 unless is_type("array", $data)
227 165 460 unless $schema->{'uniqueItems'}
228 249 211 if is_elements_unique($data, my $equal_indices = [])
236 8 76 unless exists $state->{'_num_contains'}
237 0 76 unless is_type("array", $data)
240 32 44 if $state->{'_num_contains'} > $schema->{'maxContains'}
248 8 94 unless exists $state->{'_num_contains'}
249 0 94 unless is_type("array", $data)
252 34 60 if $state->{'_num_contains'} < $schema->{'minContains'}
260 146 210 unless is_type("object", $data)
261 108 102 if keys %$data <= $schema->{'maxProperties'}
263 12 90 $schema->{'maxProperties'} > 1 ? :
269 146 210 unless is_type("object", $data)
270 108 102 if keys %$data >= $schema->{'minProperties'}
272 6 96 $schema->{'minProperties'} > 1 ? :
276 0 1715 unless assert_keyword_type($state, $schema, "array")
278 0 1715 if &any(sub {
279 0 1715 unless is_elements_unique($schema->{'required'})
284 158 1565 unless is_type("object", $data)
287 854 711 unless @missing
288 36 675 @missing > 1 ? :
292 0 320 unless assert_keyword_type($state, $schema, "object")
297 0 336 unless is_type("array", $schema->{'dependentRequired'}{$property})
301 1 349 unless is_type("string", $schema->{'dependentRequired'}{$property}[$index])
305 0 336 unless is_elements_unique($schema->{'dependentRequired'}{$property})
311 105 185 unless is_type("object", $data)
315 36 165 unless exists $data->{$property}
317 85 80 if (my(@missing) = grep((!exists $data->{$_}), @{$$schema{"dependentRequired"}{$property}}))
318 5 80 @missing > 1 ? :
323 100 85 if $valid
328 8 2587 unless assert_keyword_type($state, $schema, "number")
333 0 3309 unless assert_keyword_type($state, $schema, "integer")
335 0 3309 if $$schema{$state->{'keyword'}} < 0