Branch Coverage

blib/lib/JSON/Schema/Modern/Vocabulary/Validation.pm
Criterion Covered Total %
branch 149 170 87.6


line true false branch
39 147 20 $spec_version ne 'draft4' ? :
103 64 !($spec_version =~ /^draft[467]\z/u) ? :
103 64 !($spec_version =~ /^draft[467]\z/u) ? :
50 364 8189 if (ref $$schema{'type'} eq 'ARRAY') { }
52 0 364 unless @{$$schema{"type"}}
56 4 754 unless CORE::any {($type // "") eq $_;} "null", "boolean", "object", "array", "string", "number", "integer"
58 0 360 unless is_elements_unique($$schema{"type"})
61 4 8185 unless assert_keyword_type($state, $schema, "string")
63 4 8181 unless CORE::any {($$schema{"type"} // "") eq $_;} "null", "boolean", "object", "array", "string", "number", "integer"
69 1238 7713 $$state{'specification_version'} eq 'draft4' ? :
70 1039 7912 ref $$schema{'type'} eq 'ARRAY' ? :
72 6760 2191 if CORE::any {$_ eq "boolean" and $$state{"scalarref_booleans"} and $type eq "reference to SCALAR" 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;} @want
76 2445 6756 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
79 151 2040 @want > 1 ? :
89 429 341 if CORE::any {is_equal($data, $_, $s[$idx++] = {%s});} @{$$schema{"enum"}}
91 71 621 length $s[$_]{'path'} ? :
98 728 651 if is_equal($data, $$schema{"const"}, \%s)
99 73 578 $s{'path'} ? :
103 2 1117 unless assert_keyword_type($state, $schema, "number")
104 0 1117 if $$schema{"multipleOf"} <= 0
111 0 2 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data) and do { $data = 0 + $data; 1 }
115 767 127 if (get_type($data) eq 'integer' and get_type($$schema{'multipleOf'}) eq 'integer') { }
120 71 56 is_bignum($data) ? :
121 101 26 is_bignum($$schema{'multipleOf'}) ? :
125 477 417 if $remainder == 0
133 0 1 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data)
135 167 415 if 0 + $data < $$schema{"maximum"}
136 6 409 if ($$state{'specification_version'} eq 'draft4' and $$schema{'exclusiveMaximum'}) { }
140 163 246 if 0 + $data == $$schema{"maximum"}
146 562 18 if $$state{"specification_version"} ne "draft4"
148 0 18 unless assert_keyword_type($state, $schema, "boolean")
150 0 18 unless exists $$schema{"maximum"}
156 15 548 if $$state{"specification_version"} eq "draft4"
159 0 1 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data)
161 148 171 if 0 + $data < $$schema{"exclusiveMaximum"}
169 0 1 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data)
171 176 511 if 0 + $data > $$schema{"minimum"}
172 4 507 if ($$state{'specification_version'} eq 'draft4' and $$schema{'exclusiveMinimum'}) { }
176 184 323 if 0 + $data == $$schema{"minimum"}
182 499 16 if $$state{"specification_version"} ne "draft4"
184 0 16 unless assert_keyword_type($state, $schema, "boolean")
186 0 16 unless exists $$schema{"minimum"}
192 11 485 if $$state{"specification_version"} eq "draft4"
195 0 1 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data)
197 118 138 if 0 + $data > $$schema{"exclusiveMinimum"}
204 249 417 unless is_type("string", $data)
205 224 193 if length $data <= $$schema{"maxLength"}
212 253 368 unless is_type("string", $data)
213 199 169 if length $data >= $$schema{"minLength"}
219 1 1287 unless assert_keyword_type($state, $schema, "string") and assert_pattern($state, $$schema{"pattern"})
224 289 989 unless is_type("string", $data)
226 536 452 if $data =~ /(?:$$schema{"pattern"})/u
233 196 292 unless is_type("array", $data)
234 156 136 if @$data <= $$schema{"maxItems"}
235 32 104 $$schema{'maxItems'} > 1 ? :
241 222 309 unless is_type("array", $data)
242 167 142 if @$data >= $$schema{"minItems"}
243 124 18 $$schema{'minItems'} > 1 ? :
251 212 908 unless is_type("array", $data)
252 280 628 unless $$schema{"uniqueItems"}
253 348 280 if is_elements_unique($data, my $s = {%$state{"scalarref_booleans", "stringy_numbers"}, "equal_indices", []})
266 165 234 unless is_type("object", $data)
267 122 112 if keys %$data <= $$schema{"maxProperties"}
269 18 94 $$schema{'maxProperties'} > 1 ? :
275 165 238 unless is_type("object", $data)
276 122 116 if keys %$data >= $$schema{"minProperties"}
278 14 102 $$schema{'minProperties'} > 1 ? :
282 0 2107 unless assert_keyword_type($state, $schema, "array")
283 0 2107 if $$state{"specification_version"} eq "draft4" and not @{$$schema{"required"}}
285 0 2107 if (my(@non_string) = grep((!is_type("string", $$schema{"required"}[$_])), 0 .. $$schema{"required"}->$#*))
291 0 2107 unless is_elements_unique($$schema{"required"})
296 185 2088 unless is_type("object", $data)
299 1265 823 unless @missing
300 60 763 @missing > 1 ? :
304 0 319 unless assert_keyword_type($state, $schema, "object")
309 0 335 unless is_type("array", $$schema{"dependentRequired"}{$property})
313 1 348 unless is_type("string", $$schema{"dependentRequired"}{$property}[$index])
317 0 335 unless is_elements_unique($$schema{"dependentRequired"}{$property})
323 110 185 unless is_type("object", $data)
327 36 165 unless exists $$data{$property}
329 85 80 if (my(@missing) = grep((!exists($$data{$_})), @{$$schema{"dependentRequired"}{$property}}))
330 5 80 @missing > 1 ? :
335 100 85 if $valid
344 0 3683 unless assert_keyword_type($state, $schema, "integer")
346 0 3683 if $$schema{$$state{"keyword"}} < 0