Branch Coverage

blib/lib/JSON/Schema/Helper.pm
Criterion Covered Total %
branch 136 222 61.2


line true false branch
84 55 0 if ($schema)
88 0 55 if (not $_changing and defined $instance and ref $instance eq 'HASH' and defined $$instance{'$schema'})
96 27 28 @{$$self{'errors'};} ? :
111 0 68 if defined $$schema{$_}
116 155 30 if ($type)
123 23 132 if (ref $type eq 'ARRAY') { }
17 115 elsif (ref $type eq 'HASH') { }
34 81 elsif (not $self->jsMatchType($type, $value)) { }
129 11 40 unless @unionErrors
131 12 11 if @unionErrors
153 110 55 $path ? :
162 0 52 if defined $$schema{$_}
167 12 0 if (ref $schema ne 'HASH' and $path || ref $schema ne 'CODE')
169 0 12 if (ref $schema eq 'CODE') { }
0 12 elsif ($schema) { }
183 0 153 if ($_changing and $$schema{'readonly'})
187 0 153 if ($$schema{'extends'})
193 19 134 if (not defined $value) { }
196 2 17 if exists $schema->{'optional'}
197 14 5 if $$schema{'required'}
199 15 4 if $required
205 0 134 if (defined $$schema{'disallow'} and not $self->checkType($$schema{'disallow'}, $value, $path, $_changing))
211 128 6 unless ($self->jsIsNull($value))
213 7 121 if (ref $value eq 'ARRAY') { }
70 51 elsif (defined $$schema{'properties'} or defined $$schema{'additionalProperties'} or defined $$schema{'patternProperties'} or $$schema{'type'} eq 'object') { }
217 0 7 if (ref $items eq 'ARRAY') { }
0 7 elsif (ref $items eq 'HASH') { }
222 0 0 defined $$value[$i] ? :
226 0 0 if (exists $schema->{'additionalItems'})
229 0 0 if (not $additional_items) { }
231 0 0 if (defined $$value[$i])
240 0 0 defined $$value[$i] ? :
251 0 0 defined $$value[$i] ? :
255 0 7 if ($$schema{'minItems'} and scalar @$value < $$schema{'minItems'})
260 0 7 if ($$schema{'maxItems'} and scalar @$value > $$schema{'maxItems'})
265 0 7 if ($$schema{'uniqueItems'})
269 0 0 unless scalar keys %hash == scalar @$value
281 0 128 if ($$schema{'pattern'} and $self->jsMatchType('string', $value))
284 0 0 unless $value =~ /$x/
287 2 0 if ($$schema{'format'} and $self->jsMatchType('string', $value) || $self->jsMatchType('number', $value))
292 2 0 exists $$self{'format'}{$$schema{'format'}} ? :
295 1 1 unless match($value, $format_checker)
297 1 5 if ($$schema{'maxLength'} and $self->jsMatchType('string', $value) and length $value > $$schema{'maxLength'})
302 2 10 if ($$schema{'minLength'} and $self->jsMatchType('string', $value) and length $value < $$schema{'minLength'})
307 0 128 if (defined $$schema{'minimum'} and not $self->jsMatchType('number', $value)) { }
6 122 elsif (defined $$schema{'minimum'}) { }
309 0 0 if (defined $$schema{'minimumCanEqual'} and not $$schema{'minimumCanEqual'} or $$schema{'exclusiveMinimum'}) { }
313 0 0 if $value lt $$schema{'minimum'}
318 0 0 if $value le $$schema{'minimum'}
323 0 6 if (defined $$schema{'minimumCanEqual'} and not $$schema{'minimumCanEqual'} or $$schema{'exclusiveMinimum'}) { }
327 0 0 unless $value > $$schema{'minimum'}
332 2 4 unless $value >= $$schema{'minimum'}
335 0 128 if (defined $$schema{'maximum'} and not $self->jsMatchType('number', $value)) { }
6 122 elsif (defined $$schema{'maximum'}) { }
337 0 0 if (defined $$schema{'maximumCanEqual'} and not $$schema{'maximumCanEqual'} or $$schema{'exclusiveMaximum'}) { }
341 0 0 if $value gt $$schema{'maximum'}
346 0 0 if $value ge $$schema{'maximum'}
351 0 6 if (defined $$schema{'maximumCanEqual'} and not $$schema{'maximumCanEqual'} or $$schema{'exclusiveMaximum'}) { }
355 0 0 unless $value < $$schema{'maximum'}
360 1 5 unless $value <= $$schema{'maximum'}
363 8 120 if ($$schema{'enum'})
369 4 4 unless exists $enum{$this_value}
371 0 128 if ($$schema{'divisibleBy'} and $self->jsMatchType('number', $value)) { }
0 256 elsif ($$schema{'maxDecimal'} and $self->jsMatchType('number', $value)) { }
374 0 0 if $frac
380 0 0 if $value =~ /$regexp/
403 69 1 if (ref $objTypeDef eq 'HASH')
405 6 63 if (ref $instance ne 'HASH')
412 76 0 unless ($i =~ /^__/)
414 4 19 exists $instance->{$i} ? :
53 23 defined $$instance{$i} ? :
429 6 69 unless ($prop_is_hidden or $prop_is_explicitly_allowed or $prop_is_implicitly_allowed)
436 0 75 if (defined $requires and not defined $$instance{$requires})
442 0 75 if (defined $deps)
447 5 0 exists $instance->{$i} ? :
70 5 defined $$instance{$i} ? :
448 17 57 if (defined $objTypeDef and ref $objTypeDef eq 'HASH' and not defined $$objTypeDef{$i})
455 0 75 if (defined $patternProp)
459 0 0 if $i =~ /$pattern/
464 0 75 if (not $_changing and defined $value and ref $value eq 'HASH' and defined $$value{'$schema'})
476 18 146 if &blessed($value) and $value->isa('JSON::Schema::Null')
485 29 118 if (lc $type eq 'string')
487 2 27 ref $value ? :
490 13 105 if (lc $type eq 'number')
492 12 1 $value =~ /^\-?[0-9]*(\.[0-9]*)?$/ && length $value ? :
495 12 93 if (lc $type eq 'integer')
497 6 6 $value =~ /^\-?[0-9]+$/ ? :
500 8 85 if (lc $type eq 'boolean')
502 2 6 if ref $value eq 'JSON::Schema::Null'
503 0 0 if ref $value eq 'SCALAR' and $$value == 0 || $$value == 1
504 2 4 if $value eq 1
505 0 4 if $value eq 0
506 0 4 if ref $value eq 'JSON::PP::Boolean'
507 0 4 if ref $value eq 'JSON::XS::Boolean'
511 78 7 if (lc $type eq 'object')
513 64 14 ref $value eq 'HASH' ? :
516 6 1 if (lc $type eq 'array')
518 1 5 ref $value eq 'ARRAY' ? :
521 1 0 if (lc $type eq 'null')
526 0 0 if (lc $type eq 'any')
531 0 0 if (lc $type eq 'none')
536 0 0 if (&blessed($value) and $value->isa($type)) { }
0 0 elsif (ref $value and ref $value eq $type) { }
552 2 32 if ref $value eq 'HASH'
555 3 29 if ref $value eq 'ARRAY'
558 0 0 if ref $value eq 'SCALAR' and $$value == 0 and $$value == 1
561 0 29 if ref $value =~ /^JSON::(.*)::Boolean$/
564 11 18 if $self->jsIsNull($value)
567 0 18 if ref $value
570 6 12 if $value =~ /^\-?[0-9]+$/
573 8 4 if $value =~ /^\-?[0-9]*(\.[0-9]*)?$/