Branch Coverage

blib/lib/JSON/SchemaValidator.pm
Criterion Covered Total %
branch 91 344 26.4


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 7 9 if (_is_object($schema)) { }
3 6 elsif (_is_array($schema)) { }
151 0 7 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 7 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 6 1 if (_is_object($schema)) { }
1 0 elsif (_is_array($schema)) { }
234 0 6 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 4 0 if (_is_object($schema))
302 2 2 if (my $types = $schema->{'type'})
307 0 4 if (my $enum = $schema->{'enum'})
312 0 4 if (exists $schema->{'const'})
318 3 1 if (_is_object($json)) { }
1 0 elsif (_is_array($json)) { }
0 0 elsif (_is_number($json)) { }
0 0 elsif (_is_string($json)) { }
335 1 3 if (my $subschema_type = _subschema($schema))
342 0 4 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 2 0 unless ref $types eq 'ARRAY'
370 0 2 if (_is_object($type)) { }
1 1 elsif (not _is_type($json, $type)) { }
388 1 1 if (@results and not grep({$_->is_success;} @results))
389 1 0 if (@results == 1) { }
410 0 1 unless ref $subschemas eq 'ARRAY'
421 0 1 if ($type eq 'allOf') { }
0 1 elsif ($type eq 'anyOf') { }
1 0 elsif ($type eq 'oneOf') { }
0 0 elsif ($type eq 'not') { }
422 0 0 if (@valid != @subresults)
432 0 0 unless (@valid)
442 1 0 if (@valid != 1)
452 0 0 if (@valid)
473 2 1 exists $schema->{'required'} ? :
475 1 2 if (exists $schema->{'properties'})
479 0 2 if (exists $schema->{'properties'}{$key}{'required'} and _is_boolean($schema->{'properties'}{$key}{'required'}))
487 0 3 if (exists $schema->{'dependencies'})
489 0 0 unless exists $json->{$dependency}
491 0 0 if (_is_array($schema->{'dependencies'}{$dependency})) { }
0 0 elsif (_is_object($schema->{'dependencies'}{$dependency})) { }
498 0 0 if ($key eq 'required') { }
509 0 3 if (defined(my $min_properties = $schema->{'minProperties'}))
510 0 0 if (keys %$json < $min_properties)
520 0 3 if (defined(my $max_properties = $schema->{'maxProperties'}))
521 0 0 if (keys %$json > $max_properties)
531 2 1 if (@required)
533 2 0 unless (exists $json->{$name})
546 0 3 if (exists $schema->{'additionalProperties'})
547 0 0 if (_is_boolean($schema->{'additionalProperties'}) and not $schema->{'additionalProperties'}) { }
0 0 elsif (_is_object($schema->{'additionalProperties'})) { }
549 0 0 if (my $pattern_properties = $schema->{'patternProperties'})
551 0 0 if $additional_property =~ /$pattern_property/
565 0 0 if (my $pattern_properties = $schema->{'patternProperties'})
567 0 0 if $additional_property =~ /$pattern_property/
581 1 2 if (my $properties = $schema->{'properties'})
583 0 2 if (exists $json->{$name})
591 0 3 if (_is_object($schema->{'patternProperties'}))
612 0 1 if (defined(my $min_items = $schema->{'minItems'}))
613 0 0 if (@$json < $min_items)
623 0 1 if (defined(my $max_items = $schema->{'maxItems'}))
624 0 0 if (@$json > $max_items)
634 0 1 if (_is_array($schema->{'items'}))
639 0 0 if @$json < $i + 1
646 0 0 if ($got_length > $exp_length)
647 0 0 if (_is_boolean($schema->{'additionalItems'})) { }
0 0 elsif (_is_object($schema->{'additionalItems'})) { }
648 0 0 unless ($schema->{'additionalItems'})
668 0 1 if (_is_object($schema->{'items'}))
676 0 1 if ($schema->{'uniqueItems'})
679 0 0 defined $el ? :
0 0 ref $el ? :
681 0 0 if (exists $seen->{$hash})
694 0 1 if ($schema->{'contains'})
695 0 0 unless (@$json)
713 0 0 if (defined(my $max_length = $schema->{'maxLength'}))
714 0 0 if (length $json > $max_length)
724 0 0 if (defined(my $min_length = $schema->{'minLength'}))
725 0 0 if (length $json < $min_length)
735 0 0 if (my $pattern = $schema->{'pattern'})
736 0 0 unless ($json =~ /$pattern/)
755 0 0 if (defined(my $minimum = $schema->{'minimum'}))
756 0 0 if ($schema->{'exclusiveMinimum'}) { }
757 0 0 if ($json <= $minimum)
767 0 0 if ($json < $minimum)
778 0 0 if (_is_number($schema->{'exclusiveMaximum'}))
781 0 0 if ($json >= $maximum)
791 0 0 if (defined(my $maximum = $schema->{'maximum'}))
792 0 0 if ($schema->{'exclusiveMaximum'}) { }
793 0 0 if ($json >= $maximum)
803 0 0 if ($json > $maximum)
814 0 0 if (defined(my $divisibleBy = $schema->{'divisibleBy'}))
815 0 0 if (sprintf('%0.6f', $json) ne sprintf('%0.6f', int($json / $divisibleBy) * $divisibleBy))
825 0 0 if (defined(my $multipleOf = $schema->{'multipleOf'}))
826 0 0 if (sprintf('%0.6f', $json) ne sprintf('%0.6f', int($json / $multipleOf) * $multipleOf))
847 0 0 ref $el ? :
851 0 0 defined $json ? :
0 0 ref $json ? :
853 0 0 unless (exists $set->{$hash})
873 0 0 if (_is_type($json, $exp_type) or $exp_type eq 'integer' and _type($json) eq 'number') { }
874 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)) { }
875 0 0 if ('JSON'->new->utf8->canonical->encode($json) ne 'JSON'->new->utf8->canonical->encode($const))
884 0 0 if (sprintf('%0.6f', $const) ne sprintf('%0.6f', $json))
894 0 0 if ($json ne $const)
904 0 0 if ($const != $json)
947 0 11 unless defined $value
948 0 11 if ref $value
949 0 11 if &JSON::is_bool($value)
953 7 4 if $flags & 12288 and not $flags & 16384
963 0 10 unless defined $value
964 0 10 if ref $value
965 0 10 if &JSON::is_bool($value)
969 4 6 if $flags & 4096 and not $flags & 16384
977 0 6 unless defined $value
978 4 2 if ref $value
979 0 2 if _is_boolean($value)
980 0 2 if _is_number($value)
988 17 3 defined $value ? :
996 3 8 if ($type eq 'number')
997 1 2 if $real_type eq 'integer'
1002 0 0 _type($value) eq $type ? :
1008 2 17 if _is_null($value)
1009 3 14 if _is_object($value)
1010 3 11 if _is_array($value)
1011 2 9 if _is_boolean($value)
1012 3 6 if _is_integer($value)
1013 4 2 if _is_number($value)
1014 2 0 if _is_string($value)
1023 1 14 if $schema->{$_}
1037 0 0 if (exists $context->{'ids'}{$url}) { }
0 0 elsif ($context->{'remote_cache'}{$url}) { }
1047 0 0 if ($schema)
1054 0 0 if ($schema and $pointer)