Branch Coverage

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


line true false branch
156 0 161 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 11440 unless (defined $directive)
406 0 8318 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 257 $self->error_count ? :
739 0 144 unless $field_a and $field_b
746 0 144 unless $field_a and $field_b
756 444 849 unless $directives->get($key)->mixin
760 265 584 if ($field_a->has($key))
762 219 46 unless $directives->get($key)->multi
766 630 0 if ($directives->get($key)->field)
770 271 359 if ($directives->get($key)->multi) { }
774 20 251 if (isa_arrayref($field_a->{$key})) { }
776 20 0 isa_arrayref($value) ? :
790 122 129 isa_arrayref($value) ? :
816 0 454 unless $field and $mixin
829 1632 216 if ($field->has($key))
831 1291 341 unless $directives->get($key)->multi
835 557 0 if ($directives->get($key)->field)
839 386 171 if ($directives->get($key)->multi) { }
843 339 47 if (isa_arrayref($field->{$key})) { }
845 329 10 isa_arrayref($value) ? :
859 44 3 isa_arrayref($value) ? :
861 2 45 if $field->{$key}
897 0 617 unless $self->{'package'} eq ref $context
924 0 1009 unless $field
927 294 715 if $field->can("mixin") and $field->{'mixin'}
937 0 1009 unless $field
941 22 987 if $field->can("mixin_field") and $field->{'mixin_field'}
961 355 654 $field->{'label'} ? :
963 16 993 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 2 148 if $name =~ s/^\+{2}//
1279 1 149 if $name =~ s/^\+{1}//
1281 0 150 unless $name =~ /^(?:[a-zA-Z_](?:[\w\.]*\w|\w*)(?:\:\d+)?)$/
1284 3 147 if ($merge)
1285 2 1 if ($self->configuration->fields->has($name) and $merge == 2)
1290 1 0 if ($self->configuration->fields->has($name) and $merge == 1)
1297 0 147 if $self->fields->has($name)
1300 0 147 if $package->can($name)
1318 65 18 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 12 35 $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 12 35 if ($output and $output_type eq 'output') { }
0 35 elsif ($output) { }
1458 9 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 8 28 if ($output)
1516 2 6 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 14 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 16 if (my $alias = &firstval(sub { exists $data->{$_}; } , @keys))
1641 0 2 isa_arrayref($alias) ? :
1653 11 7 if (my $alias = &firstval(sub { exists $data->{$_}; } , @keys))
1659 11 0 if ($alias)
1661 3 8 isa_arrayref($alias) ? :
1665 11 0 if (@roles)
1675 0 13 unless ($self->registry->has($role))
1692 2 11 if (defined $requirements)
1697 1 1 unless ($self->package->can($requirement))
1702 1 1 if (@failures)
1719 12 0 if (@routines)
1725 38 793 unless $self->package->can($routine)
1748 120 12 if (ref $rp_attr and $rp_attr->isa($map)) { }
12 0 elsif (ref $rp_attr and $rp_attr->isa($lst)) { }
1859 8 0 if @errors
1884 0 5950 if $name eq 'proto' || $name eq 'prototype' and $self->package->can($name)
1921 0 0 if $field->{'readonly'}
1946 167 0 if (my $config = $self->configuration->configure_profile)
1982 4 9619 if @_ == 1 and not ref $_[0]
1984 11 9608 if @_ == 1 and isa_mapping($_[0])
1985 1 9618 if @_ == 1 and isa_hashref($_[0])
1986 2 9617 if @_ > 1
2007 0 2639 unless $event
2008 0 2639 unless $field
2012 1009 1630 $event eq 'on_normalize' ? :
2013 1009 1630 $event eq 'on_normalize' ? :
2018 0 2639 unless defined $event
2019 0 2639 unless defined $field
2027 0 2639 unless @order
2034 29061 12108 unless ($process_all)
2035 20101 8960 unless exists $field->{$i}
2044 16891 4177 $self->params->has($name) ? :
2071 0 411 unless $self->{'package'} eq ref $context
2084 1 410 if (isa_hashref($fields[0]))
2100 36 375 if (@{$self->queued;})
2108 2 515 isa_regexp($_) ? :
2117 34 489 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 313 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 379 31 unless ($self->stash->{'validation.bypass_event'})
2199 239 140 if $self->is_valid
2213 1 409 if (defined $alias_map)
2223 239 171 $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}))