lib/FormValidator/Lite/Constraint/HTML.pm

filter: Statementstmt 100% 41 / 41 Branchbran 71.4% 10 / 14 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 1 totaltotal 83.3% 65 / 78 CC 10 SCAR 12.1
CC
10
Cov
87%
__ANON__
5.7
__ANON__
5.7
__ANON__
2.0
CRAP 3.3
« lib/FormValidator/Simple/Plugin/HTML.pm ↑ Summary blib/lib/HTML/ValidationRules.pm »
1 package FormValidator::Lite::Constraint::HTML;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Scalar::Util::Numeric ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use FormValidator::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use FormValidator::Lite::Constraint;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 FormValidator::Lite->load_constraints(qw(URL Email));
11  
12 1 our $VERSION = '0.01';
13  
14 10 ▶sub rule_of ($) {
Subroutine rule_of: called CC=1 SCAR=0.0
Pod undocumented
15 10 $FormValidator::Lite::Rules->{$_[0]};
16 }
17  
18 1 rule HTML_URL => rule_of('HTTP_URL');
19 1 rule HTML_EMAIL => rule_of('EMAIL');
20  
21 14 ▶rule HTML_NUMBER => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
22 14 ▶ Scalar::Util::Numeric::isnum($_) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
&Scalar::Util::Numeric::isnum($_) ? : 12 2 14
23 1 };
24  
25 1 rule HTML_RANGE => rule_of('HTML_NUMBER');
26  
27 2 ▶rule HTML_MAXLENGTH => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
28 2 rule_of('LENGTH')->(0, shift);
29 1 };
30  
31 3 ▶rule HTML_MAX => sub {
Subroutine __ANON__: called CC=5 SCAR=17.5
32 3 my ($max) = @_;
33  
34 3 ▶ return if !Scalar::Util::Numeric::isnum($_);
Branch: 1 branch
BranchTrueFalseTotal
unless &Scalar::Util::Numeric::isnum($_) 0 3 3
35 3 ▶ croak 'Validation HTML_MAX requires numeric value'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $max and &Scalar::Util::Numeric::isnum($max) 0 3 3
Condition33%1/3
defined $max and &Scalar::Util::Numeric::isnum($max)
!ll&&!rl&&r
003
MC/DC0%0/2
defined $max and &Scalar::Util::Numeric::isnum($max)
defined $max &Scalar::Util::Numeric::isnum($max)
Truth table33%1/3
A and B
A= defined $maxB= &Scalar::Util::Numeric::isnum($max)
ABresult
0X0
100
111
36 if !defined $max || !Scalar::Util::Numeric::isnum($max);
37  
38 3 ▶ $_ <= $max ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_ <= $max ? : 2 1 3
39 1 };
40  
41 5 ▶rule HTML_MIN => sub {
Subroutine __ANON__: called CC=5 SCAR=17.5
42 5 my ($min) = @_;
43  
44 5 ▶ return if !Scalar::Util::Numeric::isnum($_);
Branch: 1 branch
BranchTrueFalseTotal
unless &Scalar::Util::Numeric::isnum($_) 0 5 5
45 5 ▶ croak 'Validation HTML_MIN requires numeric value'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $min and &Scalar::Util::Numeric::isnum($min) 0 5 5
Condition33%1/3
defined $min and &Scalar::Util::Numeric::isnum($min)
!ll&&!rl&&r
005
MC/DC0%0/2
defined $min and &Scalar::Util::Numeric::isnum($min)
defined $min &Scalar::Util::Numeric::isnum($min)
Truth table33%1/3
A and B
A= defined $minB= &Scalar::Util::Numeric::isnum($min)
ABresult
0X0
100
111
46 if !defined $min || !Scalar::Util::Numeric::isnum($min);
47  
48 5 ▶ $_ >= $min ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_ >= $min ? : 3 2 5
49 1 };
50  
51 5 ▶rule HTML_PATTERN => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
52 5 rule_of('REGEX')->('^(?:' . shift() . ')$');
53 1 };
54  
55 1 !!1;
« lib/FormValidator/Simple/Plugin/HTML.pm ↑ Summary blib/lib/HTML/ValidationRules.pm »