Branch Coverage

lib/JSON/Structure/SchemaValidator.pm
Criterion Covered Total %
branch 170 408 41.6


line true false branch
142 0 27 if ($args{'external_schemas'})
144 0 0 if (ref $schema eq "HASH" and exists $schema->{'$id'})
175 1 65 if (defined $source_text) { }
184 0 66 unless (defined $doc)
190 0 66 if (ref $doc ne "HASH")
197 0 66 if $self->{'allow_import'}
200 3 63 if $self->{'extended'}
206 56 10 if (exists $doc->{'$schema'})
212 64 2 if (exists $doc->{'$id'})
217 3 63 if (exists $doc->{'$uses'})
222 0 62 if (exists $doc->{'type'} and exists $doc->{'$root'})
231 62 4 if (exists $doc->{'type'})
236 0 66 if (exists $doc->{'$root'})
241 1 65 if (exists $doc->{'definitions'})
242 0 1 if (ref $doc->{'definitions'} ne 'HASH') { }
253 0 66 if (exists $doc->{'$offers'})
258 0 66 if ($self->{'extended'} and not exists $doc->{'type'})
268 4 0 unless ($has_type or $has_root or $has_composition)
277 3 63 if ($self->{'extended'})
299 1 30 $self->{'source_locator'} ? :
318 0 0 $self->{'source_locator'} ? :
334 0 3 unless ref $schema eq "HASH"
341 0 19 if (exists $ALL_VALIDATION_KEYWORDS{$key} and not $has_uses)
351 3 0 if (exists $schema->{'type'})
354 0 3 if ($type eq 'array' and exists $schema->{'items'}) { }
0 3 elsif ($type eq 'map' and exists $schema->{'values'}) { }
0 3 elsif ($type eq 'object') { }
0 3 elsif ($type eq 'tuple' and exists $schema->{'items'} and ref $schema->{'items'} eq 'ARRAY') { }
363 0 0 if (exists $schema->{'properties'} and ref $schema->{'properties'} eq "HASH")
373 0 0 if (exists $schema->{'optionalProperties'} and ref $schema->{'optionalProperties'} eq "HASH")
397 0 9 if (exists $schema->{$comp_key} and ref $schema->{$comp_key} eq "ARRAY")
409 0 3 if (exists $schema->{'if'})
413 0 0 if exists $schema->{'then'}
416 0 0 if exists $schema->{'else'}
420 0 3 if (exists $schema->{'definitions'} and ref $schema->{'definitions'} eq "HASH")
431 0 0 unless ref $defs eq "HASH"
435 0 0 if (ref $val eq "HASH")
436 0 0 if (exists $val->{'type'}) { }
453 2 64 unless (exists $obj->{'$id'})
459 2 64 if (exists $obj->{'type'} and not exists $obj->{'name'})
468 0 120 if (not defined $value or ref $value)
474 9 111 if (not $value =~ /$ABSOLUTE_URI_REGEX/u)
487 0 3 if ($schema_uri =~ /extended|validation/u)
488 0 0 if ($schema_uri =~ /validation/u)
496 3 0 if (ref $uses eq "ARRAY")
498 3 0 if (exists $KNOWN_EXTENSIONS{$ext})
508 0 3 if (ref $uses ne "ARRAY")
516 0 3 if (not defined $ext or ref $ext) { }
0 3 elsif ($self->{'extended'} and not exists $KNOWN_EXTENSIONS{$ext}) { }
533 0 0 if (ref $offers ne "ARRAY")
541 0 0 if (not defined $ext or ref $ext)
551 0 3 unless ref $obj eq "HASH"
554 0 21 if exists $obj->{$key}
564 0 9 if (exists $obj->{$keyword})
570 0 3 if (exists $obj->{'not'})
571 0 0 if (ref $obj->{'not'} ne 'HASH') { }
581 0 3 if (exists $obj->{'if'})
582 0 0 if (ref $obj->{'if'} ne 'HASH') { }
591 0 3 if (exists $obj->{'then'})
592 0 0 if (ref $obj->{'then'} ne 'HASH') { }
601 0 3 if (exists $obj->{'else'})
602 0 0 if (ref $obj->{'else'} ne 'HASH') { }
615 0 0 if (ref $arr ne "ARRAY")
621 0 0 if (@$arr == 0)
629 0 0 if (ref $schema ne 'HASH') { }
645 0 0 if (not defined $pointer or ref $pointer)
653 0 0 if (not defined $target)
665 0 2 if $pointer eq "" or $pointer eq "/"
668 2 0 if @segments and $segments[0] eq ""
678 3 0 if (ref $current eq 'HASH') { }
0 0 elsif (ref $current eq 'ARRAY') { }
679 1 2 unless exists $current->{$segment}
683 0 0 unless $segment =~ /^\d+$/u
685 0 0 if $idx >= @$current
705 0 2 $self->{'allow_dollar'} ? :
706 0 2 unless ($name =~ /$id_regex/u)
712 0 2 if (ref $def ne "HASH")
719 0 0 unless (exists $def->{'type'} or exists $def->{'$ref'} or $self->_has_composition_keywords($def))
726 0 0 if (ref $def->{$key} eq "HASH" and exists $def->{$key}{'type'} || exists $def->{$key}{'$ref'})
737 0 0 if ($has_nested)
757 0 98 if ($self->{'current_depth'} > $self->{'max_validation_depth'})
768 0 98 unless (ref $schema)
769 0 0 if ($schema eq 1 or $schema eq 0 or _is_json_bool($schema) or $schema eq "true" or $schema eq "false")
780 0 98 if (ref $schema ne "HASH")
788 60 38 if (exists $schema->{'name'})
790 0 60 $self->{'allow_dollar'} ? :
791 0 60 if (not defined $schema->{'name'} or ref $schema->{'name'} or not $schema->{'name'} =~ /$id_regex/u)
803 0 98 if (not defined $type) { }
806 0 0 if ($self->{'extended'} and $self->_has_composition_keywords($schema))
813 0 0 if (exists $schema->{'$ref'})
818 0 0 unless ($is_root)
823 0 0 if (exists $schema->{$kw})
829 0 0 unless ($has_defining or exists $schema->{'$ref'})
840 20 78 if (exists $schema->{'properties'})
845 9 89 if (exists $schema->{'required'})
851 2 96 if (exists $schema->{'items'})
856 1 97 if (exists $schema->{'values'})
861 1 97 if (exists $schema->{'choices'})
867 1 97 if (exists $schema->{'tuple'})
873 3 95 if (exists $schema->{'enum'})
878 0 98 if (exists $schema->{'const'})
884 0 98 if (exists $schema->{'additionalProperties'})
890 0 98 if (exists $schema->{'$extends'})
895 1 97 if (exists $schema->{'definitions'})
896 0 1 if (ref $schema->{'definitions'} ne 'HASH') { }
908 3 95 if ($self->{'extended'})
916 0 98 if (exists $schema->{'altnames'})
929 0 98 unless (defined $type)
933 96 2 if (not ref $type) { }
0 2 elsif (ref $type eq 'ARRAY') { }
2 0 elsif (ref $type eq 'HASH') { }
942 0 0 if (@$type == 0)
950 0 0 if (not defined $t or ref $t) { }
963 0 2 if (not exists $type->{'$ref'}) { }
980 64 32 if exists $PRIMITIVE_TYPES{$type_name}
981 28 4 if exists $COMPOUND_TYPES{$type_name}
991 3 93 if ($type eq 'array' or $type eq 'set') { }
2 91 elsif ($type eq 'map') { }
2 89 elsif ($type eq 'tuple') { }
2 87 elsif ($type eq 'choice') { }
992 1 2 if (not exists $schema->{'items'} || exists $schema->{'contains'})
998 1 1 if (not exists $schema->{'values'})
1004 1 1 if (not exists $schema->{'properties'} && exists $schema->{'tuple'})
1011 1 1 if (not exists $schema->{'choices'})
1021 0 2 if (not defined $ref or ref $ref)
1027 0 2 if (exists $self->{'seen_refs'}{$ref})
1038 1 1 if (not defined $target) { }
1044 0 0 if ($ref =~ /^$id/u)
1050 1 0 unless ($found)
1057 1 0 if (ref $target eq "HASH" and exists $target->{'type'})
1069 0 1 unless ref $schema eq "HASH"
1072 0 1 unless defined $type
1074 0 0 if (ref $type eq "HASH" and exists $type->{'$ref'})
1076 0 0 if ($nested_ref eq $original_ref) { }
0 0 elsif (exists $self->{'seen_refs'}{$nested_ref}) { }
1094 0 20 if (ref $properties ne "HASH")
1105 29 0 if (ref $prop_schema eq 'HASH') { }
0 0 elsif (not ref $prop_schema) { }
1122 0 9 if (ref $required ne "ARRAY")
1132 0 10 if (not defined $prop or ref $prop)
1142 10 0 if (defined $properties and ref $properties eq "HASH")
1143 1 9 unless (exists $properties->{$prop})
1157 2 0 if (ref $items eq 'HASH') { }
0 0 elsif (not ref $items) { }
1173 1 0 if (ref $values eq 'HASH') { }
0 0 elsif (not ref $values) { }
1189 0 1 if (ref $choices ne "HASH")
1196 0 1 if (keys %$choices == 0)
1204 2 0 if (ref $choice_schema eq 'HASH') { }
0 0 elsif (not ref $choice_schema) { }
1225 0 1 if (ref $tuple ne "ARRAY")
1235 1 0 if (defined $properties and ref $properties eq "HASH")
1238 0 2 if (not defined $prop or ref $prop)
1245 0 2 unless (exists $properties->{$prop})
1259 0 3 if (ref $enum ne "ARRAY")
1265 1 2 if (@$enum == 0)
1277 1 5 if (exists $seen{$key})
1290 0 6 if (not defined $value) { }
6 0 elsif (not ref $value) { }
0 0 elsif (ref $value eq 'ARRAY') { }
0 0 elsif (ref $value eq 'HASH') { }
1312 0 0 if (ref $additional eq 'HASH') { }
0 0 elsif (not ref $additional) { }
1318 0 0 if (not $additional =~ /^[01]$/u || _is_json_bool($additional) and $additional ne "true" and $additional ne "false")
1337 0 0 if (not defined $extends or ref $extends)
1345 0 0 if (exists $self->{'seen_extends'}{$extends})
1358 0 0 if (not defined $target)
1378 0 15 if (exists $schema->{$keyword} and not $is_numeric)
1395 0 18 if (exists $schema->{$keyword} and not $is_string)
1415 2 13 if (exists $schema->{$keyword})
1417 0 2 if (not defined $value or ref $value or not $value =~ /^-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?$/u)
1431 1 0 if (exists $schema->{'minimum'} and exists $schema->{'maximum'})
1432 1 0 if ($schema->{'minimum'} > $schema->{'maximum'})
1438 0 0 if (exists $schema->{'minLength'} and exists $schema->{'maxLength'})
1439 0 0 if ($schema->{'minLength'} > $schema->{'maxLength'})
1445 0 0 if (exists $schema->{'minItems'} and exists $schema->{'maxItems'})
1446 0 0 if ($schema->{'minItems'} > $schema->{'maxItems'})
1453 0 3 if (exists $schema->{'minItems'})
1455 0 0 if (defined $value and not ref $value and $value =~ /^-?\d+$/u and $value < 0)
1466 0 3 if (exists $schema->{'minLength'})
1468 0 0 if (defined $value and not ref $value and $value =~ /^-?\d+$/u and $value < 0)
1480 0 3 if (exists $schema->{'multipleOf'})
1482 0 0 if (defined $value and not ref $value and $value =~ /^-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?$/u)
1486 0 0 if ($value <= 0)
1497 2 1 if (exists $schema->{'pattern'})
1499 0 2 if (not defined $pattern or ref $pattern) { }
1506 1 1 unless ($pattern_ok)
1515 0 3 if (exists $schema->{'uniqueItems'})
1517 0 0 if (not _is_boolean($value))
1540 0 0 unless defined $value and builtin::blessed($value)
1542 0 0 if $value->isa($class)
1544 0 0 if JSON::MaybeXS::is_bool($value)
1552 0 0 if _is_json_bool($value)
1553 0 0 if ref $value
1554 0 0 if $value =~ /^[01]$/u
1555 0 0 if $value eq "true" or $value eq "false"
1562 0 0 if (ref $altnames ne "HASH")
1570 0 0 if (not defined $value or ref $value)
1584 0 0 unless ref $obj eq "HASH"
1587 0 0 if ($key eq '$import' or $key eq '$importdefs') { }
0 0 elsif (ref $obj->{$key} eq 'HASH') { }
0 0 elsif (ref $obj->{$key} eq 'ARRAY') { }
1592 0 0 if (not defined $uri or ref $uri)
1602 0 0 if (ref $obj->{$key}[$i] eq "HASH")