Nested/Validator/String.pm

filter: Statementstmt 100% 44 / 44 Branchbran 100% 14 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 7 totaltotal 91.4% 75 / 82 CC 9 SCAR 6.4
CC
9
Cov
100%
between_length
3.0
max_length
2.0
length
2.0
CRAP 1.9
« Nested/Validator/Bool.pm ↑ Summary Nested/Validator/Blank.pm »
1 package FormValidator::Nested::Validator::String;
2 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use List::MoreUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 57 ▶sub max_length {
Subroutine max_length: called CC=2 SCAR=6.9
Pod undocumented
10 57 my ( $value, $options, $req ) = @_;
11  
12 57 ▶ if ( length $value > $options->{max} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $value > $options->{"max"}) 2 55 57
13 2 return 0;
14 }
15 55 return 1;
16 }
17  
18 3 ▶sub length {
Subroutine length: called CC=2 SCAR=6.9
Pod undocumented
19 3 my ( $value, $options, $req ) = @_;
20  
21 3 ▶ if ( length $value != $options->{'length'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::length $value != $options->{"length"}) 2 1 3
22 2 return 0;
23 }
24 1 return 1;
25 }
26  
27 4 ▶sub between_length {
Subroutine between_length: called CC=3 SCAR=11.0
Pod undocumented
28 4 my ( $value, $options, $req ) = @_;
29  
30 4 my $length = CORE::length $value;
31 4 ▶ if ( $length < $options->{'min'} || $length > $options->{'max'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length < $options->{"min"} or $length > $options->{"max"}) 2 2 4
Condition100%3/3
$length < $options->{"min"} or $length > $options->{"max"}
l!l&&r!l&&!r
112
MC/DC100%2/2
$length < $options->{"min"} or $length > $options->{"max"}
$length < $options->{"min"} $length > $options->{"max"}
Truth table100%3/3
A or B
A= $length < $options->{"min"}B= $length > $options->{"max"}
ABresult
1X1
011
000
32 2 return 0;
33 }
34 2 return 1;
35 }
36  
37 6 ▶sub alpha_num {
Subroutine alpha_num: called CC=2 SCAR=6.9
Pod undocumented
38 6 my ( $value, $options, $req ) = @_;
39  
40 6 ▶ if ( $value =~ /[^0-9a-zA-Z]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /[^0-9a-zA-Z]/) 3 3 6
41 3 return 0;
42 }
43 3 return 1;
44 }
45  
46 5 ▶sub ascii {
Subroutine ascii: called CC=2 SCAR=6.9
Pod undocumented
47 5 my ( $value, $options, $req ) = @_;
48  
49 5 ▶ if ( $value =~ /\P{ASCII}/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /\P{ASCII}/) 2 3 5
50 2 return 0;
51 }
52 3 return 1;
53 }
54  
55 3 ▶sub in {
Subroutine in: called CC=2 SCAR=6.9
Pod undocumented
56 3 my ( $value, $options, $req ) = @_;
57  
58 3 ▶ if ( List::MoreUtils::none { $value eq $_ } @{$options->{list}} ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (&List::MoreUtils::none(sub { $value eq $_; } , @{$$options{"list"};})) 1 2 3
59 1 return 0;
60 }
61 2 return 1;
62 }
63  
64 4 ▶sub no_break {
Subroutine no_break: called CC=2 SCAR=6.9
Pod undocumented
65 4 my ( $value, $options, $req ) = @_;
66  
67 4 ▶ if ( $value =~ /[\x{0a}\x{0d}]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /[\x{0a}\x{0d}]/) 3 1 4
68 3 return 0;
69 }
70 1 return 1;
71 }
72  
73  
74 8 1;
75  
« Nested/Validator/Bool.pm ↑ Summary Nested/Validator/Blank.pm »