Branch Coverage

lib/HTTP/Validate.pm
Criterion Covered Total %
branch 389 510 76.2


line true false branch
730 0 9 unless defined $class
760 14 63 ref $_[0] eq 'HTTP::Validate' ? :
771 2 74 unless defined $ruleset_name and not ref $ruleset_name and $ruleset_name ne ''
833 18 42 ref $_[0] eq 'HTTP::Validate' ? :
890 12 3 ref $_[0] eq 'HTTP::Validate' ? :
897 5 29 if ($key eq 'allow_unrecognized') { }
2 27 elsif ($key eq 'ignore_unrecognized') { }
24 3 elsif ($ERROR_MSG{$key}) { }
899 5 0 $value ? :
904 2 0 $value ? :
938 0 2 ref $_[0] eq 'HTTP::Validate' ? :
976 0 4 ref $_[0] eq 'HTTP::Validate' ? :
982 0 4 unless defined $ruleset_name
985 0 4 unless $rs
1011 0 1 ref $_[0] eq 'HTTP::Validate' ? :
1017 0 1 unless defined $ruleset_name
1020 0 1 unless $rs
1043 0 74 if $ruleset_name eq ''
1045 2 72 if (exists $validator->{'RULESETS'}{$ruleset_name})
1123 16 184 if (not ref $rule) { }
0 184 elsif (&reftype($rule) ne 'HASH') { }
1127 5 11 if ($rule =~ qr/ ^ ([!^?] | >>?) (.*) /sx) { }
1134 1 4 if ($1 eq '>>') { }
1 3 elsif ($1 eq '>') { }
1 2 elsif ($1 eq '!') { }
1 1 elsif ($1 eq '^') { }
1136 1 0 if $doc_rule or @doc_lines
1214 2 4 unless $DIRECTIVE{$key} or $ERROR_MSG{$key}
1216 183 139 if (defined $DIRECTIVE{$key} and $DIRECTIVE{$key} == 2)
1218 1 182 if $type
1232 95 225 if ($key eq 'valid') { }
3 222 elsif ($key eq 'alias') { }
4 218 elsif ($key eq 'clean') { }
3 215 elsif ($key eq 'default') { }
8 207 elsif ($key eq 'split' or $key eq 'list') { }
7 200 elsif ($key eq 'error' or $key eq 'errmsg') { }
19 181 elsif ($key ne $type) { }
1235 0 95 unless $CATEGORY{$type} eq 'param' or $type eq 'content_type'
1241 0 3 unless $CATEGORY{$type} eq 'param'
1243 0 3 if ref $value and ref $value ne 'ARRAY'
1246 1 2 ref $value ? :
1252 0 4 unless $CATEGORY{$type} eq 'param'
1257 0 4 unless ref $rr->{'cleaner'} eq 'CODE'
1263 0 3 unless $CATEGORY{$type} eq 'param'
1271 0 8 unless $CATEGORY{$type} eq 'param'
1273 0 8 if ref $value and ref $value ne 'Regexp'
1282 7 1 unless (ref $value)
1288 5 3 if $key eq 'list'
1298 0 19 if ref $value
1304 0 181 unless $type
1311 176 5 if ($CATEGORY{$type} ne 'modifier')
1335 131 50 if ($CATEGORY{$type} eq 'param') { }
5 45 elsif ($CATEGORY{$type} eq 'modifier') { }
31 14 elsif ($CATEGORY{$type} eq 'include') { }
10 4 elsif ($CATEGORY{$type} eq 'constraint') { }
4 0 elsif ($type eq 'content_type') { }
1342 1 130 unless defined $typevalue and not ref $typevalue and $typevalue ne ''
1347 3 127 ref $rule->{'valid'} eq 'ARRAY' ? :
1351 6 126 if (defined $v and $VALIDATOR_DEF{$v}) { }
87 39 elsif (defined $v) { }
1353 2 4 if $v eq 'FLAG_VALUE'
1354 2 4 if $v eq 'FLAG_VALUE'
1359 2 85 unless ref $v and &reftype($v) eq 'CODE'
1366 28 100 if $type eq 'optional' or $type eq 'mandatory'
1368 104 24 if ($type ne 'optional')
1370 104 0 unless $rs->{'params'}{$typevalue}
1380 3 125 if (defined $rr->{'default'})
1382 0 3 if ref $rr->{'default'}
1385 1 2 unless ref $rr->{'validators'} eq 'ARRAY' and @{$rr->{'validators'};}
1391 0 2 unless defined $result
1393 1 1 if (exists $result->{'value'})
1396 0 1 if ref $rr->{'default'}
1410 4 1 ref $typevalue eq 'ARRAY' ? :
1420 0 5 unless @{$rr->{'param'};} > 0
1426 6 25 if $type eq 'require'
1429 1 29 unless defined $typevalue and not ref $typevalue and $typevalue ne ''
1432 1 28 unless defined $self->{'RULESETS'}{$typevalue}
1443 0 10 unless defined $typevalue and ref $typevalue eq 'ARRAY'
1448 0 20 unless defined $arg and $arg ne ''
1450 0 20 unless defined $rs->{'includes'}{$arg}
1455 0 10 unless @{$rr->{'ruleset'};} > 0
1465 0 4 if ref $typevalue or not $typevalue =~ /\w/
1467 4 0 ref $rule->{'valid'} eq 'ARRAY' ? :
1471 0 10 if ($t eq '')
1480 1 9 unless $long
1483 0 9 if defined $rr->{'type_map'}{$short}
1489 0 3 unless $rr->{'type_map'}
1527 66 172 unless defined $rr or @lines
1533 1 171 if @lines and $lines[0] =~ /^[!]/
1538 1 165 if defined $rr and $rr->{'undocumented'}
1557 4 11 if ($body ne '')
1559 0 4 if $last_pod or $this_pod
1571 5 165 if (not defined $rr) { }
125 40 elsif (defined $rr and $rr->{'type'} eq 'param') { }
27 13 elsif (defined $rr and $rr->{'type'} eq 'include') { }
1574 5 0 if defined $body
1583 125 0 if defined $body
1596 1 26 if ($body ne '')
1599 1 0 if defined $body
1619 0 0 if ($1 eq '=over') { }
0 0 elsif ($1 eq '=back') { }
0 0 elsif ($1 eq '=item') { }
0 0 elsif ($1 eq '=head') { }
1627 0 0 if $list_level < 0
1632 0 0 if $list_level == 0
1637 0 0 if $list_level > 0 or $item_body
1659 0 6 if $state->{'processed'}{$rs->{'name'}}
1669 0 6 unless ref $rs and ref $rs->{'doc_items'} eq 'ARRAY'
1678 10 28 if (ref $item and defined $item->{'param'}) { }
8 20 elsif ($item =~ qr/ ^ =ORDINARY /x) { }
2 18 elsif ($item =~ qr/ ^ =INCLUDE \s* (.*) /sx) { }
1680 5 5 unless ($state->{'in_list'})
1682 2 3 if $doc ne ''
1694 3 5 if ($state->{'in_list'})
1696 3 0 if $doc ne ''
1708 2 0 if (ref $included_rs eq 'HTTP::Validate::Ruleset')
1712 2 0 if $doc ne '' and $subdoc ne ''
1713 2 0 if $subdoc ne ''
1721 14 4 if $doc ne '' and $item ne ''
1730 4 2 if (--$state->{'level'} == 0)
1732 2 2 if $state->{'in_list'}
1752 0 3 if $uniq->{$rs_name}
1758 5 2 if ($rule->{'type'} eq 'param') { }
2 0 elsif ($rule->{'type'} eq 'include') { }
1784 0 60 if defined $context and !ref($context) || &reftype($context) ne 'HASH'
1787 0 60 unless defined $context
1789 0 60 unless ref $input_params
1796 29 31 if (&reftype($input_params) eq 'HASH') { }
31 0 elsif (&reftype($input_params) eq 'ARRAY') { }
1824 0 72 if (ref $p) { }
1867 0 78 if (ref $hash->{$param} and &reftype($hash->{$param}) eq 'ARRAY') { }
3 75 elsif (defined $hash->{$param} and $hash->{$param} ne '') { }
1869 0 0 ref $value && &reftype($value) eq 'ARRAY' ? :
1878 0 3 ref $value && &reftype($value) eq 'ARRAY' ? :
1900 0 60 unless defined $ruleset_name and $ruleset_name ne ''
1901 0 60 if ref $ruleset_name or not $ruleset_name =~ /\w/
1912 1 59 if ($vr->{'rs'}{$ruleset_name} != 2)
1915 1 0 @names == 1 ? :
1939 3 1 if defined $vr->{'content_type'} and $vr->{'content_type'} ne '' and $vr->{'content_type'} ne 'unknown'
1952 8 52 if $self->{'SETTINGS'}{'ignore_unrecognized'}
1956 105 4 if exists $vr->{'ps'}{$key} or exists $vr->{'ig'}{$key}
1958 2 2 if ($self->{'SETTINGS'}{'permissive'}) { }
1984 0 82 unless defined $ruleset_name
1990 0 82 unless ref $rs
1995 0 82 if exists $vr->{'rs'}{$ruleset_name}
2000 35 47 unless ref $rs->{'fulfill_order'} and @{$rs->{'fulfill_order'};}
2016 170 44 if ($type eq 'param') { }
0 44 elsif ($rr->{'type'} eq 'ignore') { }
12 32 elsif ($rr->{'type'} eq 'together' or $rr->{'type'} eq 'at_most_one') { }
22 10 elsif ($rr->{'type'} eq 'include') { }
6 4 elsif ($rr->{'type'} eq 'constraint') { }
4 0 elsif ($type eq 'content_type') { }
2022 0 170 if $vr->{'ig'}{$key}
2029 62 115 unless exists $vr->{'raw'}{$name}
2032 116 2 if defined $_
3 112 ref $v eq 'ARRAY' ? :
2035 115 0 unless exists $vr->{'ps'}{$name}
2044 1 169 if (keys %names_found > 1 and not $rr->{'multiple'}) { }
0 169 elsif (exists $vr->{'clean'}{$key}) { }
1 168 elsif (not @raw_values and exists $rr->{'default'}) { }
2 331 elsif (@raw_values > 1 and not $rr->{'multiple'}) { }
2048 1 0 unless $rr->{'optional'}
2081 2 0 unless $rr->{'optional'}
2088 20 146 if ($rr->{'split'})
2092 22 0 if defined $_
2100 2 1 if ($rr->{'flag'} and keys %names_found and not @raw_values)
2108 67 99 unless (@raw_values)
2110 2 65 if ($rr->{'mandatory'})
2114 2 0 unless $rr->{'optional'}
2138 40 71 unless ($rr->{'validators'})
2140 40 0 if (defined $raw_val and $raw_val ne '')
2142 4 36 if ref $rr->{'cleaner'} eq 'CODE'
2163 4 67 unless ref $result and &reftype($result) eq 'HASH'
2169 42 25 unless $result->{'error'}
2175 25 42 if (ref $result and $result->{'error'})
2181 8 17 if ($rr->{'warn'}) { }
2184 0 8 $rr->{'warn'} ne '1' ? :
2204 1 41 if (ref $result and $result->{'warn'})
2213 41 5 ref $result && exists $result->{'value'} ? :
2218 0 46 if ref $rr->{'cleaner'} eq 'CODE'
2227 78 21 if (@clean_values) { }
2231 7 71 if ($rr->{'multiple'}) { }
2249 2 19 if (defined $rr->{'bad_value'} and $rr->{'bad_value'} eq 'ERROR') { }
1 18 elsif (defined $rr->{'bad_value'}) { }
2259 1 0 $rr->{'multiple'} ? :
2271 22 77 $error_flag ? :
2278 77 22 unless ($rr->{'optional'})
2323 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) { }
2354 1 21 if ($rr->{'require'} and not $vr->{'rs'}{$rs_name} == 2)
2360 0 1 @missing == 1 ? :
2378 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') { }
2386 0 4 @missing == 1 ? :
2403 4 0 if ref $self->{'RULESETS'}{$rs}{'fulfill_order'} eq 'ARRAY'
2424 3 1 if ($rr->{'type_map'}{$value}) { }
2452 0 14 if exists $scratch->{$arg}
2472 17 17 if ($msg =~ qr/^ERR_/)
2483 0 8 $rr->{'type'} eq 'content_type' ? :
24 8 $rr->{'type'} eq 'param' ? :
2 32 $rr->{'key'} ? :
2511 1 10 if ($msg =~ qr/^ERR_/)
2522 0 2 $rr->{'type'} eq 'content_type' ? :
9 2 $rr->{'type'} eq 'param' ? :
0 11 $rr->{'key'} ? :
2541 0 11 if $rr->{'errmsg'}
2543 2 9 if ($rr->{'warn'}) { }
2545 1 1 if $rr->{'warn'} ne '1'
2566 42 4 if (ref $value) { }
4 0 elsif (defined $value and not $value =~ /^'/) { }
2568 42 0 if (&reftype($value) eq 'ARRAY') { }
0 0 elsif (&reftype($value) eq 'HASH') { }
2588 46 0 if defined $value and $value ne ''
2601 0 42 unless @names
2625 2 5 if ref $self->{'er'} eq 'ARRAY' and @{$self->{'er'};}
2647 20 30 if (not wantarray) { }
4 26 elsif (defined $key) { }
2649 4 16 defined $key ? :
12 8 unless defined $key ? ref $self->{'ec'} : ref $self->{'er'}
2650 3 5 defined $key ? :
2658 1 3 unless ref $self->{'ec'}
2697 18 11 if (not wantarray) { }
2 9 elsif (defined $key) { }
2699 2 16 defined $key ? :
12 6 unless defined $key ? ref $self->{'wc'} : ref $self->{'wn'}
2700 2 4 defined $key ? :
2708 0 2 unless ref $self->{'wn'}
2871 9 34 unless ($value =~ /^([+-]?\d+)$/)
2876 7 27 if (defined $min and $value < $min)
2878 5 0 $min == 1 ? :
1 5 $min == 0 ? :
1 6 defined $max ? :
2886 1 26 if (defined $max and $value > $max)
2888 1 0 defined $min ? :
2900 1 14 unless not defined $min or $min =~ /^[+-]?\d+$/
2901 0 14 unless not defined $max or $max =~ /^[+-]?\d+$/
2903 8 6 unless defined $min or defined $max
2937 1 13 unless ($value =~ /^[+-]?(?:\d+\.\d*|\d*\.\d+|\d+)(?:[eE][+-]?\d+)?$/)
2942 4 4 if (defined $min and defined $max and $value < $min || $value > $max)
2947 0 9 if (defined $min and $value < $min)
2952 0 9 if (defined $max and $value > $max)
2964 1 14 if defined $min and not &looks_like_number($min)
2965 0 14 if defined $max and not &looks_like_number($max)
2967 8 6 unless defined $min or defined $max
2988 4 3 if $value =~ /$pattern/
2996 2 8 unless defined $pattern and !ref($pattern) || ref $pattern eq 'Regexp'
2999 4 4 ref $pattern ? :
3029 4 1 if exists $accepted->{$folded}
3042 0 9 unless defined $k and $k ne ''
3044 0 9 if ($k eq '#')
3051 9 0 unless $undoc
3055 1 4 unless keys %accepted
3077 2 0 unless (ref $value)
3079 2 0 if ($value =~ /^(?:1|yes|true|on)$/i) { }
0 0 elsif ($value =~ /^(?:0|no|false|off)$/i) { }