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'})
473 0 0 if $schema->{'properties'}{$key}{'required'}
477 0 0 if (exists $schema->{'dependencies'})
479 0 0 unless exists $json->{$dependency}
481 0 0 if (_is_array($schema->{'dependencies'}{$dependency})) { }
0 0 elsif (_is_object($schema->{'dependencies'}{$dependency})) { }
488 0 0 if ($key eq 'required') { }
499 0 0 if (defined(my $min_properties = $schema->{'minProperties'}))
500 0 0 if (keys %$json < $min_properties)
510 0 0 if (defined(my $max_properties = $schema->{'maxProperties'}))
511 0 0 if (keys %$json > $max_properties)
521 0 0 if (@required)
523 0 0 unless (exists $json->{$name})
536 0 0 if (exists $schema->{'additionalProperties'})
537 0 0 if (_is_boolean($schema->{'additionalProperties'}) and not $schema->{'additionalProperties'}) { }
0 0 elsif (_is_object($schema->{'additionalProperties'})) { }
539 0 0 if (my $pattern_properties = $schema->{'patternProperties'})
541 0 0 if $additional_property =~ /$pattern_property/
555 0 0 if (my $pattern_properties = $schema->{'patternProperties'})
557 0 0 if $additional_property =~ /$pattern_property/
571 0 0 if (my $properties = $schema->{'properties'})
573 0 0 if (exists $json->{$name})
581 0 0 if (_is_object($schema->{'patternProperties'}))
602 0 1 if (defined(my $min_items = $schema->{'minItems'}))
603 0 0 if (@$json < $min_items)
613 0 1 if (defined(my $max_items = $schema->{'maxItems'}))
614 0 0 if (@$json > $max_items)
624 0 1 if (_is_array($schema->{'items'}))
629 0 0 if @$json < $i + 1
636 0 0 if ($got_length > $exp_length)
637 0 0 if (_is_boolean($schema->{'additionalItems'})) { }
0 0 elsif (_is_object($schema->{'additionalItems'})) { }
638 0 0 unless ($schema->{'additionalItems'})
658 0 1 if (_is_object($schema->{'items'}))
666 0 1 if ($schema->{'uniqueItems'})
669 0 0 defined $el ? :
0 0 ref $el ? :
671 0 0 if (exists $seen->{$hash})
684 0 1 if ($schema->{'contains'})
685 0 0 unless (@$json)
703 0 0 if (defined(my $max_length = $schema->{'maxLength'}))
704 0 0 if (length $json > $max_length)
714 0 0 if (defined(my $min_length = $schema->{'minLength'}))
715 0 0 if (length $json < $min_length)
725 0 0 if (my $pattern = $schema->{'pattern'})
726 0 0 unless ($json =~ /$pattern/)
745 0 0 if (defined(my $minimum = $schema->{'minimum'}))
746 0 0 if ($schema->{'exclusiveMinimum'}) { }
747 0 0 if ($json <= $minimum)
757 0 0 if ($json < $minimum)
768 0 0 if (_is_number($schema->{'exclusiveMaximum'}))
771 0 0 if ($json >= $maximum)
781 0 0 if (defined(my $maximum = $schema->{'maximum'}))
782 0 0 if ($schema->{'exclusiveMaximum'}) { }
783 0 0 if ($json >= $maximum)
793 0 0 if ($json > $maximum)
804 0 0 if (defined(my $divisibleBy = $schema->{'divisibleBy'}))
805 0 0 if (sprintf('%0.6f', $json) ne sprintf('%0.6f', int($json / $divisibleBy) * $divisibleBy))
815 0 0 if (defined(my $multipleOf = $schema->{'multipleOf'}))
816 0 0 if (sprintf('%0.6f', $json) ne sprintf('%0.6f', int($json / $multipleOf) * $multipleOf))
837 0 0 ref $el ? :
841 0 0 defined $json ? :
0 0 ref $json ? :
843 0 0 unless (exists $set->{$hash})
863 0 0 if (_is_type($json, $exp_type) or $exp_type eq 'integer' and _type($json) eq 'number') { }
864 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)) { }
865 0 0 if ('JSON'->new->utf8->canonical->encode($json) ne 'JSON'->new->utf8->canonical->encode($const))
874 0 0 if (sprintf('%0.6f', $const) ne sprintf('%0.6f', $json))
884 0 0 if ($json ne $const)
894 0 0 if ($const != $json)
937 0 11 unless defined $value
938 0 11 if ref $value
939 0 11 if &JSON::is_bool($value)
943 7 4 if $flags & 12288 and not $flags & 16384
953 0 10 unless defined $value
954 0 10 if ref $value
955 0 10 if &JSON::is_bool($value)
959 4 6 if $flags & 4096 and not $flags & 16384
967 0 3 unless defined $value
968 1 2 if ref $value
969 0 2 if _is_boolean($value)
970 0 2 if _is_number($value)
978 16 3 defined $value ? :
986 3 7 if ($type eq 'number')
987 1 2 if $real_type eq 'integer'
992 0 0 _type($value) eq $type ? :
998 2 16 if _is_null($value)
999 2 14 if _is_object($value)
1000 3 11 if _is_array($value)
1001 2 9 if _is_boolean($value)
1002 3 6 if _is_integer($value)
1003 4 2 if _is_number($value)
1004 2 0 if _is_string($value)
1013 0 4 if $schema->{$_}
1027 0 0 if (exists $context->{'ids'}{$url}) { }
0 0 elsif ($context->{'remote_cache'}{$url}) { }
1037 0 0 if ($schema)
1044 0 0 if ($schema and $pointer)