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 8173 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 8169 unless assert_keyword_type($state, $schema, "string")
63 4 8165 unless CORE::any {($$schema{"type"} // "") eq $_;} "null", "boolean", "object", "array", "string", "number", "integer"
69 1238 7704 $$state{'specification_version'} eq 'draft4' ? :
70 1039 7903 ref $$schema{'type'} eq 'ARRAY' ? :
72 6751 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 6747 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 270 71 !grep($our $_{'path'}, @s) ? :
99 726 650 if is_equal($data, $$schema{"const"}, \%s)
100 73 577 $s{'path'} ? :
104 2 1117 unless assert_keyword_type($state, $schema, "number")
105 0 1117 if $$schema{"multipleOf"} <= 0
112 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 }
116 767 127 if (get_type($data) eq 'integer' and get_type($$schema{'multipleOf'}) eq 'integer') { }
121 71 56 is_bignum($data) ? :
122 101 26 is_bignum($$schema{'multipleOf'}) ? :
126 477 417 if $remainder == 0
134 0 1 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data)
136 167 415 if 0 + $data < $$schema{"maximum"}
137 6 409 if ($$state{'specification_version'} eq 'draft4' and $$schema{'exclusiveMaximum'}) { }
141 163 246 if 0 + $data == $$schema{"maximum"}
147 562 18 if $$state{"specification_version"} ne "draft4"
149 0 18 unless assert_keyword_type($state, $schema, "boolean")
151 0 18 unless exists $$schema{"maximum"}
157 15 548 if $$state{"specification_version"} eq "draft4"
160 0 1 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data)
162 148 171 if 0 + $data < $$schema{"exclusiveMaximum"}
170 0 1 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data)
172 176 511 if 0 + $data > $$schema{"minimum"}
173 4 507 if ($$state{'specification_version'} eq 'draft4' and $$schema{'exclusiveMinimum'}) { }
177 184 323 if 0 + $data == $$schema{"minimum"}
183 499 16 if $$state{"specification_version"} ne "draft4"
185 0 16 unless assert_keyword_type($state, $schema, "boolean")
187 0 16 unless exists $$schema{"minimum"}
193 11 485 if $$state{"specification_version"} eq "draft4"
196 0 1 unless is_type("number", $data) or $$state{"stringy_numbers"} and is_type("string", $data) and &looks_like_number($data)
198 118 138 if 0 + $data > $$schema{"exclusiveMinimum"}
205 249 417 unless is_type("string", $data)
206 224 193 if length $data <= $$schema{"maxLength"}
213 253 368 unless is_type("string", $data)
214 199 169 if length $data >= $$schema{"minLength"}
220 1 1287 unless assert_keyword_type($state, $schema, "string") and assert_pattern($state, $$schema{"pattern"})
225 289 989 unless is_type("string", $data)
227 536 452 if $data =~ /(?:$$schema{"pattern"})/u
234 196 292 unless is_type("array", $data)
235 156 136 if @$data <= $$schema{"maxItems"}
236 32 104 $$schema{'maxItems'} > 1 ? :
242 222 309 unless is_type("array", $data)
243 167 142 if @$data >= $$schema{"minItems"}
244 124 18 $$schema{'minItems'} > 1 ? :
252 212 908 unless is_type("array", $data)
253 280 628 unless $$schema{"uniqueItems"}
254 348 280 if is_elements_unique($data, my $s = {%$state{"scalarref_booleans", "stringy_numbers"}, "equal_indices", []})
267 165 234 unless is_type("object", $data)
268 122 112 if keys %$data <= $$schema{"maxProperties"}
270 18 94 $$schema{'maxProperties'} > 1 ? :
276 165 238 unless is_type("object", $data)
277 122 116 if keys %$data >= $$schema{"minProperties"}
279 14 102 $$schema{'minProperties'} > 1 ? :
283 0 2107 unless assert_keyword_type($state, $schema, "array")
284 0 2107 if $$state{"specification_version"} eq "draft4" and not @{$$schema{"required"}}
286 0 2107 if (my(@non_string) = grep((!is_type("string", $$schema{"required"}[$_])), 0 .. $$schema{"required"}->$#*))
292 0 2107 unless is_elements_unique($$schema{"required"})
297 185 2088 unless is_type("object", $data)
300 1265 823 unless @missing
301 60 763 @missing > 1 ? :
305 0 319 unless assert_keyword_type($state, $schema, "object")
310 0 335 unless is_type("array", $$schema{"dependentRequired"}{$property})
314 1 348 unless is_type("string", $$schema{"dependentRequired"}{$property}[$index])
318 0 335 unless is_elements_unique($$schema{"dependentRequired"}{$property})
324 110 185 unless is_type("object", $data)
328 36 165 unless exists $$data{$property}
330 85 80 if (my(@missing) = grep((!exists($$data{$_})), @{$$schema{"dependentRequired"}{$property}}))
331 5 80 @missing > 1 ? :
336 100 85 if $valid
345 0 3683 unless assert_keyword_type($state, $schema, "integer")
347 0 3683 if $$schema{$$state{"keyword"}} < 0