Branch Coverage

blib/lib/Validation/Class/Prototype.pm
Criterion Covered Total %
branch 305 466 65.4


line true false branch
156 0 159 unless defined $arguments->{'package'} and $arguments->{'package'} =~ /\w/
176 0 31 unless $field and $filter
178 9 22 if ($self->params->has($name))
180 9 0 if (isa_coderef($filter))
182 9 0 if (my $value = $self->params->get($name))
184 0 9 if (isa_arrayref($value)) { }
217 47 0 if ($spec->filtering)
219 47 0 if ($spec->filtering eq $state)
222 1 46 unless isa_arrayref($spec->filters)
243 56 470 unless $field and $mixin
249 0 470 unless $mixin and $field
253 69 401 isa_arrayref($mixin) ? :
259 25 454 unless $mixin
273 0 144 unless $field_a and $field_b
285 0 144 unless $field_a and $field_b
287 144 0 if $field_b->has('name')
288 23 121 if $field_b->has('label')
296 144 0 if defined $name
297 19 125 if defined $label
299 144 0 if $field_a->can('mixin')
311 0 0 $field->{'label'} ? :
316 0 0 $field->{'required'} ? :
318 0 0 if (defined $field->{'toggle'})
320 0 0 if $field->{'toggle'} eq '+'
321 0 0 if $field->{'toggle'} eq '-'
325 0 0 if ($req and !defined($value) || $value eq '')
328 0 0 defined $field->{'error'} ? :
336 0 0 if ($req or $value)
344 0 0 if ($directive)
346 0 0 if ($directive->{'validator'})
348 0 0 if ('CODE' eq ref $directive->{'validator'})
381 1 11385 unless (defined $directive)
406 0 8216 unless (defined $directive)
426 0 11 unless $name
432 11 0 /\w/ ? :
436 0 11 unless $class
459 0 77 unless $class->can($_)
463 0 11 unless $class->can('new')
464 0 11 unless $self->registry->has($class)
470 0 0 $child->can('prototype') ? :
11 0 $child->can('proto') ? :
475 11 0 if ($proto_method)
479 11 0 if (defined $settings{'params'})
483 2 11 if ($key =~ /^$name\.(.*)/)
485 2 0 if ($proto->fields->has($1))
532 122 0 unless $directives->{'name'}
553 4 1 &firstval(sub { $_ eq $role; } , @{$roles;}) ? :
5 0 $roles ? :
577 0 0 unless @fields
583 0 0 if ($field->{'errors'}->count)
616 0 0 if ($hash)
635 19 0 if (not @criteria) { }
0 0 elsif (isa_regexp($criteria[0])) { }
668 0 0 unless @fields
670 0 0 unless $self->fields->get($_)
690 0 11 if (@params) { }
693 0 0 defined $params->{$_} ? :
0 0 @params ? :
712 0 0 unless @fields
717 0 0 $field->readonly ? :
731 147 253 $self->error_count ? :
739 0 144 unless $field_a and $field_b
746 0 144 unless $field_a and $field_b
756 445 850 unless $directives->get($key)->mixin
760 269 581 if ($field_a->has($key))
762 222 47 unless $directives->get($key)->multi
766 628 0 if ($directives->get($key)->field)
770 271 357 if ($directives->get($key)->multi) { }
774 21 250 if (isa_arrayref($field_a->{$key})) { }
776 21 0 isa_arrayref($value) ? :
790 125 125 isa_arrayref($value) ? :
816 0 454 unless $field and $mixin
829 1648 176 if ($field->has($key))
831 1292 356 unless $directives->get($key)->multi
835 532 0 if ($directives->get($key)->field)
839 410 122 if ($directives->get($key)->multi) { }
843 354 56 if (isa_arrayref($field->{$key})) { }
845 330 24 isa_arrayref($value) ? :
859 43 13 isa_arrayref($value) ? :
861 2 54 if $field->{$key}
897 0 610 unless $self->{'package'} eq ref $context
924 0 1002 unless $field
927 294 708 if $field->can('mixin') and $field->{'mixin'}
937 0 1002 unless $field
941 22 980 if $field->can('mixin_field') and $field->{'mixin_field'}
961 355 647 $field->{'label'} ? :
963 16 986 if (defined $field->{'alias'})
966 16 0 'ARRAY' eq ref $field->{'alias'} ? :
970 0 16 if ($mapper->{$alias})
977 0 0 $alt_field->{'label'} ? :
989 0 16 if ($self->fields->has($alias))
1028 8 2 if (defined $value) { }
1033 0 2 unless $self->params->has($name)
1046 7 2 if ($self->ignore_unknown) { }
1048 2 5 if ($self->report_unknown)
1067 0 0 unless $name
1075 0 0 /\w/ ? :
1162 0 14 unless $attribute =~ /^[a-zA-Z_]\w*$/
1165 0 14 if ref $default and ref $default ne 'CODE'
1168 0 14 if isa_hashref($default)
1173 0 14 if ($settings)
1174 0 0 if (defined $settings->{'isa'})
1176 0 0 unless defined $settings->{'isa'} and $settings->{'isa'} eq 'ro'
1181 10 4 if (defined $default) { }
1185 20 11 if (@_ == 1)
1186 13 7 if exists $_[0]{$attribute}
1187 2 5 ref $default eq 'CODE' ? :
1200 4 2 if @_ == 1
1256 0 2 unless $code
1278 1 147 if $name =~ s/^\+{2}//
1279 1 147 if $name =~ s/^\+{1}//
1281 0 148 unless $name =~ /^(?:[a-zA-Z_](?:[\w\.]*\w|\w*)(?:\:\d+)?)$/
1284 2 146 if ($merge)
1285 1 1 if ($self->configuration->fields->has($name) and $merge == 2)
1290 1 0 if ($self->configuration->fields->has($name) and $merge == 1)
1297 0 146 if $self->fields->has($name)
1300 0 146 if $package->can($name)
1318 64 17 if (@_ == 1)
1359 16 2 unless ($data->{'overwrite'})
1361 0 16 if $self->attributes->has($name)
1366 0 16 if $package->can($name)
1384 0 18 unless grep {$data->{$_};} @input_keys, @output_keys
1395 0 18 unless 'CODE' eq ref $data->{'using'}
1413 45 2 $input_type ? :
1414 10 37 $output_type ? :
1418 41 6 if ($input and $input_type eq 'input') { }
4 2 elsif ($input) { }
1420 33 8 if (isa_arrayref($input)) { }
6 2 elsif ($self->proto->profiles->get($input)) { }
2 0 elsif ($self->proto->methods->get($input)) { }
1446 4 0 if ($type and $type_list and $self->proto->$type_list->get($input)) { }
1456 10 37 if ($output and $output_type eq 'output') { }
0 37 elsif ($output) { }
1458 7 3 if (isa_arrayref($output)) { }
3 0 elsif ($self->proto->profiles->get($output)) { }
0 0 elsif ($self->proto->methods->get($output)) { }
1484 0 0 if ($type and $type_list and $self->proto->$type_list->get($output)) { }
1494 47 0 if ($using)
1496 47 0 if (isa_coderef($using)) { }
1501 45 2 if ($input)
1502 11 34 unless (&$i_validator(@args))
1503 0 11 unless $self->ignore_failure
1505 0 11 if $self->report_failure
1515 7 29 if ($output)
1516 2 5 unless &$o_validator(@args)
1550 0 19 if $name =~ s/^\+{2}//
1551 0 19 if $name =~ s/^\+{1}//
1555 0 19 if ($mixins->has($name) and $merge == 2)
1560 0 19 if ($mixins->has($name) and $merge == 1)
1596 4 13 if (my $alias = &firstval(sub { exists $data->{$_}; } , @keys))
1602 3 1 if ($alias eq 1 and not ref $alias) { }
1610 1 0 isa_arrayref($alias) ? :
1635 2 15 if (my $alias = &firstval(sub { exists $data->{$_}; } , @keys))
1641 0 2 isa_arrayref($alias) ? :
1653 10 7 if (my $alias = &firstval(sub { exists $data->{$_}; } , @keys))
1659 10 0 if ($alias)
1661 3 7 isa_arrayref($alias) ? :
1665 10 0 if (@roles)
1675 0 12 unless ($self->registry->has($role))
1692 2 10 if (defined $requirements)
1697 1 1 unless ($self->package->can($requirement))
1702 1 1 if (@failures)
1719 11 0 if (@routines)
1725 37 725 unless $self->package->can($routine)
1748 110 11 if (ref $rp_attr and $rp_attr->isa($map)) { }
11 0 elsif (ref $rp_attr and $rp_attr->isa($lst)) { }
1859 8 0 if @errors
1884 0 5870 if $name eq 'proto' || $name eq 'prototype' and $self->package->can($name)
1921 0 0 if $field->{'readonly'}
1946 165 0 if (my $config = $self->configuration->configure_profile)
1982 4 9535 if @_ == 1 and not ref $_[0]
1984 11 9524 if @_ == 1 and isa_mapping($_[0])
1985 1 9534 if @_ == 1 and isa_hashref($_[0])
1986 2 9533 if @_ > 1
2007 0 2618 unless $event
2008 0 2618 unless $field
2012 1002 1616 $event eq 'on_normalize' ? :
2013 1002 1616 $event eq 'on_normalize' ? :
2018 0 2618 unless defined $event
2019 0 2618 unless defined $field
2027 0 2618 unless @order
2034 28827 12024 unless ($process_all)
2035 19933 8894 unless exists $field->{$i}
2044 16744 4174 $self->params->has($name) ? :
2071 0 406 unless $self->{'package'} eq ref $context
2084 1 405 if (isa_hashref($fields[0]))
2100 36 370 if (@{$self->queued;})
2108 2 510 isa_regexp($_) ? :
2117 34 484 if ($switch)
2123 32 2 if (my $field = $self->fields->get($field))
2125 31 1 if $switch eq '+'
2126 1 31 if $switch eq '-'
2136 308 98 if (@fields and $self->params->count) { }
78 20 elsif (not @fields and $self->params->count) { }
20 0 elsif (@fields and not $self->params->count) { }
2171 1 12 if ($_->has('alias'))
1 8 if grep {if ($_->has('alias')) { my(@aliases) = isa_arrayref($_->get('alias')) ? @{$_->get('alias');} : $_->get('alias'); grep {$f eq $_;} @aliases; } ;} $self->fields->values
2173 1 0 isa_arrayref($_->get('alias')) ? :
2194 375 30 unless ($self->stash->{'validation.bypass_event'})
2199 235 140 if $self->is_valid
2213 1 404 if (defined $alias_map)
2223 235 170 $self->validated == 2 ? :
2238 1 15 if ('HASH' eq ref $ref) { }
2247 0 7 unless 'HASH' eq ref $rules
2271 0 16 unless $name
2276 0 16 unless $name and exists $documents->{$name}
2282 0 16 unless keys %{$documents;}
2293 4 69 if $document->{$key} and exists $$documents{$document->{$key}} and not $self->fields->has($document->{$key})
2313 63 42 unless $new eq $key
2353 6 157 if ($key =~ /\?{3}/)
2358 11 71 if $_ =~ /$regex/
6 0 if grep {$_ ne $key if $_ =~ /$regex/;} keys %{$_data;}
2379 1334 0 if (exists $_data->{$key})
2383 115 1219 if ($key =~ /^$regex$/)
2385 1 114 if $field =~ s/^([+-])//
2389 115 0 if $self->fields->get($field)->can('mixin')
2397 88 27 if $config->{'mixin'}
2413 115 42 if $match
2416 1 114 $switch ? :
115 42 if $match
2419 12 145 if $options->{'prune'} and not $match
2435 7 0 unless $message
2439 0 0 unless $message
2454 111 4 unless $fields->{$point}
2462 5 11 if @errors
2464 16 0 if defined $_[2]
2477 0 8 unless $self->{'package'} eq ref $context
2479 0 8 unless $name
2487 8 0 if ($input)
2504 6 2 $self->is_valid ? :
2515 0 23 unless $self->{'package'} eq ref $context
2518 0 23 unless $name
2523 23 0 if (isa_coderef($self->profiles->{$name}))