Branch Coverage

lib/HTTP/Validate.pm
Criterion Covered Total %
branch 423 542 78.0


line true false branch
743 0 17 unless defined $class
773 26 67 ref $_[0] eq 'HTTP::Validate' ? :
784 2 90 unless defined $ruleset_name and not ref $ruleset_name and $ruleset_name ne ""
846 28 50 ref $_[0] eq 'HTTP::Validate' ? :
904 20 3 ref $_[0] eq 'HTTP::Validate' ? :
911 5 29 if ($key eq 'allow_unrecognized') { }
2 27 elsif ($key eq 'ignore_unrecognized') { }
24 3 elsif ($ERROR_MSG{$key}) { }
913 5 0 $value ? :
918 2 0 $value ? :
952 0 2 ref $_[0] eq 'HTTP::Validate' ? :
990 0 4 ref $_[0] eq 'HTTP::Validate' ? :
996 0 4 unless defined $ruleset_name
998 0 4 unless my $rs = $self->{'RULESETS'}{$ruleset_name}
1024 0 1 ref $_[0] eq 'HTTP::Validate' ? :
1030 0 1 unless defined $ruleset_name
1032 0 1 unless my $rs = $self->{'RULESETS'}{$ruleset_name}
1051 1 0 ref $_[0] eq 'HTTP::Validate' ? :
1071 1 0 ref $_[0] eq 'HTTP::Validate' ? :
1077 0 1 unless defined $ruleset_name
1079 0 1 unless my $rs = $self->{'RULESETS'}{$ruleset_name}
1102 0 90 if $ruleset_name eq "" or ref $ruleset_name
1105 2 88 if (exists $validator->{'RULESETS'}{$ruleset_name})
1186 216 16 ref $rule ? :
1190 5 11 if ($rule =~ qr/ ^ ([!^?] | >>?) (.*) /sx) { }
1197 1 4 if ($1 eq '>>') { }
1 3 elsif ($1 eq '>') { }
1 2 elsif ($1 eq '!') { }
1 1 elsif ($1 eq '^') { }
1199 1 0 if $doc_rule or @doc_lines
1272 1 215 if (my $search_for = $rule->{'before'})
1278 1 0 if ($rule_i->{'type'} eq "param" and $search_for eq ($rule_i->{'param'} || $rule_i->{'optional'} || $rule_i->{'mandatory'}) or $rule_i->{'type'} eq "include" and $search_for eq $rule_i->{'ruleset'})
1293 215 1 unless ($inserted)
1306 2 4 unless $DIRECTIVE{$key} or $ERROR_MSG{$key}
1308 215 158 if (defined $DIRECTIVE{$key} and $DIRECTIVE{$key} == 2)
1310 1 214 if $type
1324 108 263 if ($key eq 'valid') { }
4 259 elsif ($key eq 'alias') { }
4 255 elsif ($key eq 'clean') { }
3 252 elsif ($key eq 'default') { }
8 244 elsif ($key eq 'split' or $key eq 'list') { }
7 237 elsif ($key eq 'error' or $key eq 'errmsg') { }
24 213 elsif ($key ne $type) { }
1327 0 108 unless $CATEGORY{$type} eq "param" or $type eq "content_type"
1333 0 4 unless $CATEGORY{$type} eq "param"
1335 0 4 if ref $value and ref $value ne "ARRAY"
1338 1 3 ref $value ? :
1344 0 4 unless $CATEGORY{$type} eq "param"
1349 0 4 unless ref $rr->{'cleaner'} eq "CODE"
1355 0 3 unless $CATEGORY{$type} eq "param"
1363 0 8 unless $CATEGORY{$type} eq "param"
1365 0 8 if ref $value and ref $value ne "Regexp"
1374 7 1 unless (ref $value)
1380 5 3 if $key eq "list"
1390 0 24 if ref $value
1396 0 213 unless $type
1404 207 6 if ($CATEGORY{$type} ne "modifier")
1415 160 53 if ($CATEGORY{$type} eq 'param') { }
6 47 elsif ($CATEGORY{$type} eq 'modifier') { }
33 14 elsif ($CATEGORY{$type} eq 'include') { }
10 4 elsif ($CATEGORY{$type} eq 'constraint') { }
4 0 elsif ($type eq 'content_type') { }
1422 1 159 unless defined $typevalue and not ref $typevalue and $typevalue ne ""
1427 3 156 ref $rule->{'valid'} eq 'ARRAY' ? :
1431 2 159 if (defined $v and $VALIDATOR_DEF{$v}) { }
104 55 elsif (defined $v) { }
1433 2 0 if $v eq "FLAG_VALUE"
1434 2 0 if $v eq "FLAG_VALUE"
1435 0 2 if $v eq "ANY_VALUE" and @validators > 1
1440 2 102 unless ref $v and builtin::reftype($v) eq "CODE"
1447 37 120 if $type eq "optional" or $type eq "mandatory"
1449 120 37 if ($type eq "param")
1451 120 0 unless $rs->{'params'}{$typevalue}
1460 3 154 if (defined $rr->{'default'})
1462 0 3 if ref $rr->{'default'}
1465 1 2 unless ref $rr->{'validators'} eq "ARRAY" and @{$rr->{'validators'};}
1471 0 2 unless defined $result
1473 1 1 if (exists $result->{'value'})
1476 0 1 if ref $rr->{'default'}
1490 5 1 ref $typevalue eq 'ARRAY' ? :
1498 0 6 unless @{$rr->{'param'};} > 0
1504 8 25 if $type eq "require"
1507 1 31 unless defined $typevalue and not ref $typevalue and $typevalue ne ""
1510 1 30 unless defined $self->{'RULESETS'}{$typevalue}
1519 30 0 if (ref $included_rs->{'includes'} eq "HASH")
1534 0 10 unless defined $typevalue and ref $typevalue eq "ARRAY"
1539 0 20 unless defined $arg and $arg ne ""
1542 0 20 unless defined $rs->{'includes'}{$arg}
1548 0 10 unless @{$rr->{'ruleset'};} > 0
1558 0 4 if ref $typevalue or not $typevalue =~ /\w/
1560 4 0 ref $rule->{'valid'} eq 'ARRAY' ? :
1564 0 10 if ($t eq "")
1573 1 9 unless $long
1576 0 9 if defined $rr->{'type_map'}{$short}
1582 0 3 unless $rr->{'type_map'}
1594 4 73 if @doc_lines
1619 82 130 unless defined $rr or @lines
1625 1 129 if @lines and $lines[0] =~ /^[!]/
1630 1 123 if defined $rr and $rr->{'undocumented'}
1649 4 11 if ($body ne "")
1651 0 4 if $last_pod or $this_pod
1663 97 26 do { $rr->{'type'} eq 'param' if defined $rr } ? :
123 5 defined $rr ? :
1666 5 0 if defined $body
1671 123 0 if defined $rr
1675 97 0 if (defined $body)
1716 0 0 if ($1 eq '=over') { }
0 0 elsif ($1 eq '=back') { }
0 0 elsif ($1 eq '=item') { }
0 0 elsif ($1 eq '=head') { }
1724 0 0 if $list_level < 0
1729 0 0 if $list_level == 0
1734 0 0 if $list_level > 0 or $is_item_body
1756 0 6 if $state->{'processed'}{$rs->{'name'}}
1766 0 6 unless ref $rs and ref $rs->{'doc_items'} eq "ARRAY"
1775 10 28 if (ref $item and defined $item->{'param'}) { }
8 20 elsif ($item =~ qr/ ^ =ORDINARY /x) { }
2 18 elsif ($item =~ qr/ ^ =INCLUDE \s* (.*) /sx) { }
1777 5 5 unless ($state->{'in_list'})
1779 2 3 if $doc ne ""
1791 3 5 if ($state->{'in_list'})
1793 3 0 if $doc ne ""
1805 2 0 if (ref $included_rs eq "HTTP::Validate::Ruleset")
1809 2 0 if $doc ne "" and $subdoc ne ""
1810 2 0 if $subdoc ne ""
1818 14 4 if $doc ne "" and $item ne ""
1827 4 2 if (--$state->{'level'} == 0)
1829 2 2 if $state->{'in_list'}
1849 0 3 if $uniq->{$rs_name}
1855 5 2 if ($rule->{'type'} eq 'param') { }
2 0 elsif ($rule->{'type'} eq 'include') { }
1881 0 2 if $uniq->{$rs_name}
1887 1 3 if (ref $item and $item->{'type'} eq 'include') { }
3 0 elsif (ref $item eq 'HASH') { }
1913 1 77 if defined $context and !ref($context) || builtin::reftype($context) ne 'HASH'
1918 1 76 unless ref $input_params
1925 40 36 if (builtin::reftype($input_params) eq 'HASH') { }
36 0 elsif (builtin::reftype($input_params) eq 'ARRAY') { }
1955 0 96 if (ref $p) { }
1998 1 102 if (ref $hash->{$param} and builtin::reftype($hash->{$param}) eq 'ARRAY') { }
4 98 elsif (defined $hash->{$param} and $hash->{$param} ne '') { }
2000 0 1 ref $value && builtin::reftype($value) eq 'ARRAY' ? :
2009 0 4 ref $value && builtin::reftype($value) eq 'ARRAY' ? :
2033 0 76 unless defined $ruleset_name and $ruleset_name ne ""
2034 0 76 if ref $ruleset_name or not $ruleset_name =~ /\w/
2045 1 74 if ($vr->{'rs'}{$ruleset_name} != 2)
2048 1 0 @names == 1 ? :
2072 3 1 if defined $vr->{'content_type'} and $vr->{'content_type'} ne "" and $vr->{'content_type'} ne "unknown"
2085 9 66 if $self->{'SETTINGS'}{'ignore_unrecognized'}
2089 141 4 if exists $vr->{'ps'}{$key} or exists $vr->{'ig'}{$key}
2091 2 2 if ($self->{'SETTINGS'}{'permissive'}) { }
2117 0 99 unless defined $ruleset_name
2123 1 98 unless ref $rs
2128 0 98 if exists $vr->{'rs'}{$ruleset_name}
2133 41 57 unless ref $rs->{'fulfill_order'} and @{$rs->{'fulfill_order'};}
2149 214 46 if ($type eq 'param') { }
1 45 elsif ($rr->{'type'} eq 'ignore') { }
12 33 elsif ($rr->{'type'} eq 'together' or $rr->{'type'} eq 'at_most_one') { }
23 10 elsif ($rr->{'type'} eq 'include') { }
6 4 elsif ($rr->{'type'} eq 'constraint') { }
4 0 elsif ($type eq 'content_type') { }
2155 0 214 if $vr->{'ig'}{$key}
2162 72 150 unless exists $vr->{'raw'}{$name}
2168 4 146 ref $v eq 'ARRAY' ? :
2170 140 15 if (defined $subv and $subv ne '') { }
12 6 elsif (defined $subv and $subv eq '') { }
2184 150 0 unless exists $vr->{'ps'}{$name}
2193 1 213 if (keys %names_found > 1 and not $rr->{'multiple'}) { }
0 213 elsif (exists $vr->{'clean'}{$key}) { }
1 212 elsif (not @raw_values and exists $rr->{'default'}) { }
2 418 elsif (@raw_values > 1 and not $rr->{'multiple'} || $rr->{'split'} || $rr->{'list'}) { }
2197 1 0 unless $rr->{'optional'} or $rr->{'mandatory'}
2231 2 0 unless $rr->{'optional'} or $rr->{'mandatory'}
2238 20 190 if ($rr->{'split'})
2245 22 0 if defined $_
2247 1 19 if @raw_values and not @new_values
2254 2 1 if ($rr->{'flag'} and keys %names_found and not @raw_values)
2264 78 132 unless (@raw_values)
2266 2 76 if ($rr->{'mandatory'})
2272 76 2 unless $rr->{'allow_empty'} and keys %names_found
2293 47 99 unless ($rr->{'validators'})
2295 47 0 if (defined $raw_val and $raw_val ne "")
2297 4 43 if ref $rr->{'cleaner'} eq "CODE"
2318 4 95 unless ref $result and builtin::reftype($result) eq "HASH"
2324 68 27 unless $result->{'error'}
2330 27 68 if (ref $result and $result->{'error'})
2335 8 19 if ($rr->{'warn'}) { }
2338 0 8 $rr->{'warn'} ne '1' ? :
2359 1 67 if (ref $result and $result->{'warn'})
2369 67 5 ref $result && exists $result->{'value'} ? :
2374 0 72 if ref $rr->{'cleaner'} eq "CODE"
2383 2 132 if ($rr->{'allow_empty'} and not @raw_values)
2385 1 1 $empty_string ? :
2392 111 23 if (@clean_values) { }
2396 8 103 if ($rr->{'multiple'}) { }
2414 2 21 if (defined $rr->{'bad_value'} and $rr->{'bad_value'} eq 'ERROR') { }
1 20 elsif (defined $rr->{'bad_value'}) { }
2424 1 0 $rr->{'multiple'} ? :
2436 24 110 $error_flag ? :
2442 98 5 unless ($rr->{'optional'} or $rr->{'mandatory'})
2485 1 11 if ($rr->{'type'} eq 'together' and @present > 0 and @present < @{$rr->{'param'};}) { }
2 13 elsif ($rr->{'type'} eq 'at_most_one' and @present > 1) { }
2516 1 22 if ($rr->{'require'} and not $vr->{'rs'}{$rs_name} == 2)
2522 0 1 @missing == 1 ? :
2540 4 2 if (@fulfilled == 0 and $rr->{'constraint'} eq 'require_one' || $rr->{'constraint'} eq 'require_any') { }
2 0 elsif (@fulfilled > 1 and $rr->{'constraint'} eq 'allow_one' || $rr->{'constraint'} eq 'require_one') { }
2548 0 4 @missing == 1 ? :
2565 4 0 if ref $self->{'RULESETS'}{$rs}{'fulfill_order'} eq "ARRAY"
2586 3 1 if ($rr->{'type_map'}{$value}) { }
2614 0 14 if exists $scratch->{$arg}
2634 17 19 if ($msg =~ qr/^ERR_/)
2645 0 8 $rr->{'type'} eq 'content_type' ? :
26 8 $rr->{'type'} eq 'param' ? :
2 34 $rr->{'key'} ? :
2673 1 10 if ($msg =~ qr/^ERR_/)
2684 0 2 $rr->{'type'} eq 'content_type' ? :
9 2 $rr->{'type'} eq 'param' ? :
0 11 $rr->{'key'} ? :
2703 0 11 if $rr->{'errmsg'}
2705 2 9 if ($rr->{'warn'}) { }
2707 1 1 if $rr->{'warn'} ne 1
2728 44 4 if (ref $value) { }
4 0 elsif (defined $value and not $value =~ /^'/) { }
2730 44 0 if (builtin::reftype($value) eq 'ARRAY') { }
0 0 elsif (builtin::reftype($value) eq 'HASH') { }
2752 48 0 if defined $value and $value ne ""
2765 0 44 unless @names
2789 4 15 if ref $self->{'er'} eq "ARRAY" and @{$self->{'er'};}
2813 21 32 if (not wantarray) { }
4 28 elsif (defined $key) { }
2815 4 17 defined $key ? :
13 8 unless defined $key ? ref $self->{'ec'} : ref $self->{'er'}
2816 3 5 defined $key ? :
2824 1 3 unless ref $self->{'ec'}
2865 18 11 if (not wantarray) { }
2 9 elsif (defined $key) { }
2867 2 16 defined $key ? :
12 6 unless defined $key ? ref $self->{'wc'} : ref $self->{'wn'}
2868 2 4 defined $key ? :
2876 0 2 unless ref $self->{'wn'}
2967 1 3 unless exists $self->{'clean'}{$param}
2969 2 1 if (ref $self->{'clean'}{$param} eq 'ARRAY') { }
3069 9 38 unless ($value =~ /^([+-]?\d+)$/)
3074 7 31 if (defined $min and $value < $min)
3076 5 0 $min == 1 ? :
1 5 $min == 0 ? :
1 6 defined $max ? :
3084 1 30 if (defined $max and $value > $max)
3086 1 0 defined $min ? :
3098 1 14 unless not defined $min or $min =~ /^[+-]?\d+$/
3099 0 14 unless not defined $max or $max =~ /^[+-]?\d+$/
3101 8 6 unless defined $min or defined $max
3135 1 13 unless ($value =~ /^[+-]?(?:\d+\.\d*|\d*\.\d+|\d+)(?:[eE][+-]?\d+)?$/)
3140 4 4 if (defined $min and defined $max and $value < $min || $value > $max)
3145 0 9 if (defined $min and $value < $min)
3150 0 9 if (defined $max and $value > $max)
3162 1 14 if defined $min and not &looks_like_number($min)
3163 0 14 if defined $max and not &looks_like_number($max)
3165 8 6 unless defined $min or defined $max
3186 4 3 if $value =~ /$pattern/
3194 2 8 unless defined $pattern and !ref($pattern) || ref $pattern eq 'Regexp'
3197 4 4 ref $pattern ? :
3227 6 2 if exists $accepted->{$folded}
3240 0 14 unless defined $k and $k ne ""
3242 1 13 if ($k eq "#")
3249 11 2 unless $undoc
3252 1 5 unless keys %accepted
3273 0 19 if (ref($value) =~ /boolean/i) { }
19 0 elsif (not ref $value) { }
3280 10 9 if ($value =~ /^(?:1|yes|true|on)$/i) { }
8 1 elsif ($value =~ /^(?:0|no|false|off)$/i) { }