Branch Coverage

blib/lib/JSON/SchemaValidator.pm
Criterion Covered Total %
branch 61 344 17.7


line true false branch
54 0 0 if length $hostname > 255
56 0 0 unless $hostname =~ qr/^$HOSTNAME_RE$/
58 0 0 if grep {length $_ > 63;} split(/\./, $hostname, 0)
65 0 0 unless $email =~ /^$EMAIL_RE$/
69 0 0 if length $hostname > 255
70 0 0 if grep {length $_ > 63;} split(/\./, $hostname, 0)
79 0 0 unless @parts > 0 and @parts < 5
82 0 0 unless $part =~ /^[0-9]+$/ and $part >= 0 and $part < 256
85 0 0 unless $parts[-1] > 0
94 0 0 unless @parts > 0 and @parts < 9
97 0 0 if $part eq ''
99 0 0 unless $part =~ /^[0-9a-f]{1,4}$/i
107 0 0 unless $date_time =~ /$DATETIME_RE/
113 0 0 unless eval { do { 'Time::Piece'->strptime(uc $date_time, '%Y-%m-%dT%T%z') } }
148 1 1 if (_is_object($schema)) { }
0 1 elsif (_is_array($schema)) { }
151 0 1 if ($schema->{'id'} and _is_string($schema->{'id'}))
157 0 0 if ($id =~ /^http/) { }
161 0 0 unless ($base_url =~ m[/$])
169 0 0 if (not $id =~ /^#/) { }
0 0 elsif ($path) { }
170 0 0 if ($id =~ m[/$]) { }
180 0 0 if ($base_url)
188 0 0 if ($base_url)
200 0 1 if ($schema->{'$ref'} and _is_string($schema->{'$ref'}))
203 0 0 unless ($ref =~ /^http/)
204 0 0 if ($ref =~ /^#/)
205 0 0 if (my $path = $new_context->{'path'})
210 0 0 if (my $base_url = $new_context->{'base_url'})
233 1 0 if (_is_object($schema)) { }
0 0 elsif (_is_array($schema)) { }
234 0 1 if ($schema->{'$ref'} and _is_string($schema->{'$ref'}))
238 0 0 if (exists $context->{'ids'}{$ref}) { }
242 0 0 unless ($ref =~ /^http/)
243 0 0 if ($ref =~ /^#/)
244 0 0 if ($context->{'path'})
249 0 0 if ($context->{'base_url'})
254 0 0 if (exists $context->{'ids'}{$ref}) { }
0 0 elsif ($ref =~ /^http/) { }
265 0 0 if ($subschema)
267 0 0 if $key eq 'definitions'
273 0 0 if $key eq 'id'
278 0 0 if ($schema->{'$ref'})
301 1 0 if (_is_object($schema))
302 1 0 if (my $types = $schema->{'type'})
307 0 1 if (my $enum = $schema->{'enum'})
312 0 1 if (exists $schema->{'const'})
318 0 1 if (_is_object($json)) { }
1 0 elsif (_is_array($json)) { }
0 0 elsif (_is_number($json)) { }
0 0 elsif (_is_string($json)) { }
335 0 1 if (my $subschema_type = _subschema($schema))
342 0 1 if (_is_string($json))
343 0 0 if (my $format = $schema->{'format'})
344 0 0 if (my $cb = $self->{'formats'}{$format})
345 0 0 unless (&$cb($json))
366 1 0 unless ref $types eq 'ARRAY'
370 0 1 if (_is_object($type)) { }
1 0 elsif (not _is_type($json, $type)) { }
388 1 0 if (@results and not grep({$_->is_success;} @results))
389 1 0 if (@results == 1) { }
410 0 0 unless ref $subschemas eq 'ARRAY'
421 0 0 if ($type eq 'allOf') { }
0 0 elsif ($type eq 'anyOf') { }
0 0 elsif ($type eq 'oneOf') { }
0 0 elsif ($type eq 'not') { }
422 0 0 if (@valid != @subresults)
431 0 0 unless (@valid)
440 0 0 if (@valid != 1)
449 0 0 if (@valid)
469 0 0 exists $schema->{'required'} ? :
471 0 0 if (exists $schema->{'properties'})
475 0 0 if (exists $schema->{'properties'}{$key}{'required'} and _is_boolean($schema->{'properties'}{$key}{'required'}))
483 0 0 if (exists $schema->{'dependencies'})
485 0 0 unless exists $json->{$dependency}
487 0 0 if (_is_array($schema->{'dependencies'}{$dependency})) { }
0 0 elsif (_is_object($schema->{'dependencies'}{$dependency})) { }
494 0 0 if ($key eq 'required') { }
505 0 0 if (defined(my $min_properties = $schema->{'minProperties'}))
506 0 0 if (keys %$json < $min_properties)
516 0 0 if (defined(my $max_properties = $schema->{'maxProperties'}))
517 0 0 if (keys %$json > $max_properties)
527 0 0 if (@required)
529 0 0 unless (exists $json->{$name})
542 0 0 if (exists $schema->{'additionalProperties'})
543 0 0 if (_is_boolean($schema->{'additionalProperties'}) and not $schema->{'additionalProperties'}) { }
0 0 elsif (_is_object($schema->{'additionalProperties'})) { }
545 0 0 if (my $pattern_properties = $schema->{'patternProperties'})
547 0 0 if $additional_property =~ /$pattern_property/
561 0 0 if (my $pattern_properties = $schema->{'patternProperties'})
563 0 0 if $additional_property =~ /$pattern_property/
577 0 0 if (my $properties = $schema->{'properties'})
579 0 0 if (exists $json->{$name})
587 0 0 if (_is_object($schema->{'patternProperties'}))
608 0 1 if (defined(my $min_items = $schema->{'minItems'}))
609 0 0 if (@$json < $min_items)
619 0 1 if (defined(my $max_items = $schema->{'maxItems'}))
620 0 0 if (@$json > $max_items)
630 0 1 if (_is_array($schema->{'items'}))
635 0 0 if @$json < $i + 1
642 0 0 if ($got_length > $exp_length)
643 0 0 if (_is_boolean($schema->{'additionalItems'})) { }
0 0 elsif (_is_object($schema->{'additionalItems'})) { }
644 0 0 unless ($schema->{'additionalItems'})
664 0 1 if (_is_object($schema->{'items'}))
672 0 1 if ($schema->{'uniqueItems'})
675 0 0 defined $el ? :
0 0 ref $el ? :
677 0 0 if (exists $seen->{$hash})
690 0 1 if ($schema->{'contains'})
691 0 0 unless (@$json)
709 0 0 if (defined(my $max_length = $schema->{'maxLength'}))
710 0 0 if (length $json > $max_length)
720 0 0 if (defined(my $min_length = $schema->{'minLength'}))
721 0 0 if (length $json < $min_length)
731 0 0 if (my $pattern = $schema->{'pattern'})
732 0 0 unless ($json =~ /$pattern/)
751 0 0 if (defined(my $minimum = $schema->{'minimum'}))
752 0 0 if ($schema->{'exclusiveMinimum'}) { }
753 0 0 if ($json <= $minimum)
763 0 0 if ($json < $minimum)
774 0 0 if (_is_number($schema->{'exclusiveMaximum'}))
777 0 0 if ($json >= $maximum)
787 0 0 if (defined(my $maximum = $schema->{'maximum'}))
788 0 0 if ($schema->{'exclusiveMaximum'}) { }
789 0 0 if ($json >= $maximum)
799 0 0 if ($json > $maximum)
810 0 0 if (defined(my $divisibleBy = $schema->{'divisibleBy'}))
811 0 0 if (sprintf('%0.6f', $json) ne sprintf('%0.6f', int($json / $divisibleBy) * $divisibleBy))
821 0 0 if (defined(my $multipleOf = $schema->{'multipleOf'}))
822 0 0 if (sprintf('%0.6f', $json) ne sprintf('%0.6f', int($json / $multipleOf) * $multipleOf))
843 0 0 ref $el ? :
847 0 0 defined $json ? :
0 0 ref $json ? :
849 0 0 unless (exists $set->{$hash})
869 0 0 if (_is_type($json, $exp_type) or $exp_type eq 'integer' and _type($json) eq 'number') { }
870 0 0 if (_is_object($json) or _is_array($json)) { }
0 0 elsif (_is_number($json)) { }
0 0 elsif (_is_string($json)) { }
0 0 elsif (_is_boolean($json)) { }
871 0 0 if ('JSON'->new->utf8->canonical->encode($json) ne 'JSON'->new->utf8->canonical->encode($const))
880 0 0 if (sprintf('%0.6f', $const) ne sprintf('%0.6f', $json))
890 0 0 if ($json ne $const)
900 0 0 if ($const != $json)
943 0 11 unless defined $value
944 0 11 if ref $value
945 0 11 if &JSON::is_bool($value)
949 7 4 if $flags & 12288 and not $flags & 16384
959 0 10 unless defined $value
960 0 10 if ref $value
961 0 10 if &JSON::is_bool($value)
965 4 6 if $flags & 4096 and not $flags & 16384
973 0 3 unless defined $value
974 1 2 if ref $value
975 0 2 if _is_boolean($value)
976 0 2 if _is_number($value)
984 16 3 defined $value ? :
992 3 7 if ($type eq 'number')
993 1 2 if $real_type eq 'integer'
998 0 0 _type($value) eq $type ? :
1004 2 16 if _is_null($value)
1005 2 14 if _is_object($value)
1006 3 11 if _is_array($value)
1007 2 9 if _is_boolean($value)
1008 3 6 if _is_integer($value)
1009 4 2 if _is_number($value)
1010 2 0 if _is_string($value)
1019 0 4 if $schema->{$_}
1033 0 0 if (exists $context->{'ids'}{$url}) { }
0 0 elsif ($context->{'remote_cache'}{$url}) { }
1043 0 0 if ($schema)
1050 0 0 if ($schema and $pointer)