Branch Coverage

lib/JSON/Structure/InstanceValidator.pm
Criterion Covered Total %
branch 305 472 64.6


line true false branch
34 1056 29 unless defined $value and builtin::blessed($value)
36 29 0 if $value->isa($class)
40 0 0 if JSON::MaybeXS::is_bool($value)
52 0 247 unless defined $value and not ref $value
55 0 247 if _is_json_bool($value)
60 219 28 $flags & 768 ? :
73 0 97 unless defined $value and not ref $value
76 0 97 if _is_json_bool($value)
180 1 480 if (defined $source_text) { }
191 0 481 unless (defined $schema)
200 3 468 if (ref $schema eq "HASH" and exists $schema->{'$root'})
202 0 3 unless (defined $resolved)
231 1 225 $self->{'source_locator'} ? :
250 0 688 if ($self->{'current_depth'} > $self->{'max_validation_depth'})
262 10 678 if (not ref $schema or _is_json_bool($schema))
263 5 5 if (_is_false($schema))
274 0 678 if (ref $schema ne "HASH")
280 5 0 if (exists $schema->{'type'} and ref $schema->{'type'} eq "HASH" and exists $schema->{'type'}{'$ref'})
286 0 5 unless (defined $resolved)
297 5 15 if $key eq "type"
306 7 666 if (exists $schema->{'const'})
307 3 4 unless ($self->_values_equal($value, $schema->{'const'}))
317 11 655 if (exists $schema->{'enum'})
320 7 17 if ($self->_values_equal($value, $enum_val))
325 4 7 unless ($found)
335 643 23 if (defined $type)
336 0 643 if (ref $type eq 'ARRAY') { }
643 0 elsif (not ref $type) { }
341 0 0 if ($self->_check_type($value, $t))
346 0 0 unless ($matched)
359 392 274 if ($self->{'extended'})
370 7 636 if ($type eq 'null') { }
12 624 elsif ($type eq 'boolean') { }
104 520 elsif ($type eq 'string') { }
91 429 elsif ($type eq 'number' or $type eq 'float' or $type eq 'double' or $type eq 'float8' or $type eq 'decimal') { }
178 251 elsif ($type eq 'integer' or exists $INT_RANGES{$type}) { }
0 251 elsif ($type eq 'int128' or $type eq 'uint128') { }
66 185 elsif ($type eq 'object') { }
17 168 elsif ($type eq 'array') { }
11 157 elsif ($type eq 'set') { }
15 142 elsif ($type eq 'map') { }
7 135 elsif ($type eq 'tuple') { }
11 124 elsif ($type eq 'choice') { }
6 118 elsif ($type eq 'any') { }
15 103 elsif ($type eq 'date') { }
18 85 elsif ($type eq 'time') { }
12 73 elsif ($type eq 'datetime') { }
18 55 elsif ($type eq 'duration') { }
15 40 elsif ($type eq 'uuid') { }
15 25 elsif ($type eq 'uri') { }
11 14 elsif ($type eq 'binary') { }
14 0 elsif ($type eq 'jsonpointer') { }
449 0 0 if ($type eq 'null') { }
0 0 elsif ($type eq 'boolean') { }
0 0 elsif ($type eq 'string') { }
0 0 elsif ($type eq 'number' or $type eq 'float' or $type eq 'double' or $type eq 'float8' or $type eq 'decimal') { }
0 0 elsif ($type eq 'integer' or exists $INT_RANGES{$type}) { }
0 0 elsif ($type eq 'object' or $type eq 'map' or $type eq 'choice') { }
0 0 elsif ($type eq 'array' or $type eq 'set' or $type eq 'tuple') { }
0 0 elsif ($type eq 'any') { }
494 5 0 unless (not defined $value or ref $value eq "" and $value eq "null")
504 5 7 unless (_is_json_bool($value))
514 18 86 unless (defined $value and not ref $value and _is_pure_string($value))
523 63 23 if ($self->{'extended'})
524 20 43 if (exists $schema->{'minLength'})
525 6 14 if ($len < $schema->{'minLength'})
535 17 46 if (exists $schema->{'maxLength'})
536 4 13 if ($len > $schema->{'maxLength'})
543 16 47 if (exists $schema->{'pattern'})
546 8 8 unless ($value =~ qr/$pattern/u)
555 0 16 unless ($pattern_ok)
562 0 63 if (exists $schema->{'format'})
572 0 0 if ($format eq 'email') { }
0 0 elsif ($format eq 'uri') { }
0 0 elsif ($format eq 'date') { }
0 0 elsif ($format eq 'time') { }
0 0 elsif ($format eq 'date-time') { }
0 0 elsif ($format eq 'uuid') { }
0 0 elsif ($format eq 'ipv4') { }
0 0 elsif ($format eq 'hostname') { }
573 0 0 unless ($value =~ /$EMAIL_REGEX/u)
580 0 0 unless ($value =~ /$URI_REGEX/u)
587 0 0 unless ($value =~ /$DATE_REGEX/u)
594 0 0 unless ($value =~ /$TIME_REGEX/u)
601 0 0 unless ($value =~ /$DATETIME_REGEX/u)
610 0 0 unless ($value =~ /$UUID_REGEX/u)
617 0 0 unless ($value =~ /$IPV4_REGEX/u)
624 0 0 unless ($value =~ /$HOSTNAME_REGEX/u)
640 10 0 if ($type eq "decimal" and defined $value and not ref $value)
643 9 1 if (_is_numeric($value) or $value =~ /^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/u)
653 11 71 unless (defined $value and not ref $value and _is_numeric($value))
667 18 4 if ($type eq 'int64' || $type eq 'uint64' and defined $value and not ref $value and $value =~ /^-?\d+$/u)
681 3 15 if ($big_val < $big_min or $big_val > $big_max)
693 18 142 unless (defined $value and not ref $value and _is_numeric($value))
701 3 139 if ($value != int $value)
709 139 0 if (exists $INT_RANGES{$type})
711 16 123 if ($value < $range->{'min'} or $value > $range->{'max'})
728 0 0 unless (defined $value)
735 0 0 if (ref $value)
743 0 0 if (&looks_like_number($value) or $value =~ /^-?\d+$/u) { }
754 0 0 if ($type eq "uint128" and $num_value < 0)
764 67 170 unless $self->{'extended'}
766 23 147 if (exists $schema->{'minimum'})
767 6 17 if ($value < $schema->{'minimum'})
774 18 152 if (exists $schema->{'maximum'})
775 4 14 if ($value > $schema->{'maximum'})
782 13 157 if (exists $schema->{'exclusiveMinimum'})
783 4 9 if ($value <= $schema->{'exclusiveMinimum'})
793 13 157 if (exists $schema->{'exclusiveMaximum'})
794 4 9 if ($value >= $schema->{'exclusiveMaximum'})
803 19 151 if (exists $schema->{'multipleOf'})
805 6 13 if ($mult != 0 and $value / $mult != int $value / $mult)
816 3 63 unless (ref $value eq "HASH")
828 7 17 unless (exists $value->{$prop})
841 63 27 if (exists $properties->{$prop_name}) { }
4 23 elsif (defined $additional) { }
847 2 2 if (_is_false($additional)) { }
2 0 elsif (ref $additional eq 'HASH') { }
863 42 21 if ($self->{'extended'})
866 4 38 if (exists $schema->{'minProperties'})
867 2 2 if ($count < $schema->{'minProperties'})
877 4 38 if (exists $schema->{'maxProperties'})
878 1 3 if ($count > $schema->{'maxProperties'})
888 0 42 if (exists $schema->{'dependentRequired'})
890 0 0 if (exists $value->{$prop})
893 0 0 unless (exists $value->{$dep})
911 1 16 unless (ref $value eq "ARRAY")
918 16 0 if (exists $schema->{'items'})
929 13 3 if ($self->{'extended'})
932 7 6 if (exists $schema->{'minItems'})
933 3 4 if ($count < $schema->{'minItems'})
940 7 6 if (exists $schema->{'maxItems'})
941 2 5 if ($count > $schema->{'maxItems'})
948 0 13 if (exists $schema->{'contains'})
957 0 0 if (@{$self->{'errors'};} == 0)
966 0 0 if ($contains_count < $min_contains)
975 0 0 if (defined $max_contains and $contains_count > $max_contains)
990 0 11 unless (ref $value eq "ARRAY")
1001 5 22 if (exists $seen{$key})
1010 11 0 if (exists $schema->{'items'})
1024 0 15 unless (ref $value eq "HASH")
1032 15 0 if (exists $schema->{'values'})
1043 12 3 if ($self->{'extended'})
1047 0 12 if (exists $schema->{'minProperties'})
1048 0 0 if ($count < $schema->{'minProperties'})
1059 0 12 if (exists $schema->{'maxProperties'})
1060 0 0 if ($count > $schema->{'maxProperties'})
1071 3 9 if (exists $schema->{'minEntries'})
1072 1 2 if ($count < $schema->{'minEntries'})
1083 3 9 if (exists $schema->{'maxEntries'})
1084 1 2 if ($count > $schema->{'maxEntries'})
1095 3 9 if (exists $schema->{'keyNames'})
1097 3 0 if (ref $key_schema eq "HASH" and exists $key_schema->{'pattern'})
1100 2 2 unless ($key =~ /$pattern/u)
1117 0 7 unless (ref $value eq "ARRAY")
1130 3 4 if ($actual_count != $expected_count)
1132 3 0 if (not defined $items or _is_false($items))
1133 1 2 if ($actual_count > $expected_count) { }
2 0 elsif ($actual_count < $expected_count) { }
1154 2 16 if $i >= $actual_count
1156 16 0 if (exists $properties->{$prop_name})
1169 0 11 unless (defined $choices and ref $choices eq "HASH")
1180 8 3 if (defined $selector) { }
1183 0 8 unless (ref $value eq "HASH")
1190 2 6 unless (exists $value->{$selector})
1200 0 6 unless (defined $choice_name and not ref $choice_name)
1209 2 4 unless (exists $choices->{$choice_name})
1234 2 4 if (@{$self->{'errors'};} == 0)
1241 1 2 if ($match_count == 0) { }
0 2 elsif ($match_count > 1) { }
1260 0 15 unless (defined $value and not ref $value)
1266 8 7 unless ($value =~ /$DATE_REGEX/u)
1274 2 5 unless (_is_valid_calendar_date($value))
1284 0 7 unless $date_str =~ /^(\d{4})-(\d{2})-(\d{2})$/u
1289 0 7 if $month < 1 or $month > 12
1290 0 7 if $day < 1 or $day > 31
1298 5 2 $valid ? :
1304 0 18 unless (defined $value and not ref $value)
1310 8 10 unless ($value =~ /$TIME_REGEX/u)
1320 0 12 unless (defined $value and not ref $value)
1327 5 7 unless ($value =~ /$DATETIME_REGEX/u)
1339 0 18 unless (defined $value and not ref $value)
1346 6 12 unless ($value =~ /$DURATION_REGEX/u and $value ne "P" and $value ne "PT")
1358 0 15 unless (defined $value and not ref $value)
1364 8 7 unless ($value =~ /$UUID_REGEX/u)
1374 0 15 unless (defined $value and not ref $value)
1380 6 9 unless ($value =~ /$URI_REGEX/u)
1390 0 11 unless (defined $value and not ref $value)
1402 2 9 if ($value eq "")
1407 1 8 unless ($value =~ m[^[A-Za-z0-9+/]*={0,2}$]u)
1412 2 7 if ($valid and length($value) % 4 != 0)
1417 5 4 if ($valid and $value =~ /=/u)
1420 0 5 unless ($value =~ m[^[A-Za-z0-9+/]*={1,2}$]u)
1425 3 6 unless ($valid)
1437 0 14 unless (defined $value and not ref $value)
1445 2 12 if $value eq ""
1447 4 8 unless ($value =~ /$JSONPOINTER_REGEX/u)
1460 2 390 if (exists $schema->{'allOf'})
1470 4 388 if (exists $schema->{'anyOf'})
1478 2 5 if (@{$self->{'errors'};} == 0)
1486 2 2 unless ($matched)
1494 5 387 if (exists $schema->{'oneOf'})
1502 5 5 if (@{$self->{'errors'};} == 0)
1509 2 3 if ($match_count != 1)
1520 4 388 if (exists $schema->{'not'})
1528 1 3 if ($matched)
1536 2 390 if (exists $schema->{'if'})
1544 2 0 if ($if_matched and exists $schema->{'then'}) { }
0 0 elsif (not $if_matched and exists $schema->{'else'}) { }
1561 0 8 if $ref eq "" or $ref eq "/"
1564 8 0 if @segments and $segments[0] eq ""
1574 16 0 if (ref $current eq 'HASH') { }
0 0 elsif (ref $current eq 'ARRAY') { }
1575 0 16 unless exists $current->{$segment}
1579 0 0 unless $segment =~ /^\d+$/u
1581 0 0 if $idx >= @$current
1596 0 0 unless (defined $a or defined $b)
1599 0 31 unless (defined $a and defined $b)
1607 3 28 if ($ref_a ne $ref_b)
1611 27 1 if ($ref_a eq '') { }
0 1 elsif ($ref_a eq 'ARRAY') { }
0 1 elsif ($ref_a eq 'HASH') { }
1617 0 0 if @$a != @$b
1619 0 0 unless $self->_values_equal($a->[$i], $b->[$i])
1626 0 0 if @keys_a != @keys_b
1628 0 0 if $keys_a[$i] ne $keys_b[$i]
1631 0 0 unless $self->_values_equal($$a{$keys_a[$i]}, $$b{$keys_b[$i]})
1643 0 27 if (not defined $value) { }
27 0 elsif (not ref $value) { }
0 0 elsif (ref $value eq 'ARRAY') { }
0 0 elsif (ref $value eq 'HASH') { }
1647 0 27 if (_is_json_bool($value))
1648 0 0 $value ? :
1669 0 14 unless defined $value
1670 0 0 if ref $value eq "" and $value eq '0' || $value eq 'false' || $value eq ''
1673 7 7 if _is_json_bool($value) and not $value