line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Simple::Plugin::HTML; |
2
|
1
|
|
|
1
|
|
985
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
922
|
use Scalar::Util::Numeric (); |
|
1
|
|
|
|
|
911
|
|
|
1
|
|
|
|
|
23
|
|
8
|
1
|
|
|
1
|
|
7
|
use FormValidator::Simple::Constants; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
84
|
|
9
|
1
|
|
|
1
|
|
6
|
use FormValidator::Simple::Exception; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub HTML_URL { |
12
|
0
|
|
|
0
|
0
|
0
|
my ($self, $params, $args) = @_; |
13
|
0
|
|
|
|
|
0
|
$self->HTTP_URL($params, $args); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub HTML_EMAIL { |
17
|
0
|
|
|
0
|
0
|
0
|
my ($self, $params, $args) = @_; |
18
|
0
|
|
|
|
|
0
|
$self->EMAIL($params, $args); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub HTML_NUMBER { |
22
|
14
|
|
|
14
|
0
|
15846
|
my ($self, $params, $args) = @_; |
23
|
14
|
|
|
|
|
23
|
my $data = $params->[0]; |
24
|
14
|
50
|
|
|
|
38
|
return FAIL if !defined $data; |
25
|
14
|
100
|
|
|
|
78
|
Scalar::Util::Numeric::isnum($data) ? SUCCESS : FAIL; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
*HTML_RANGE = \&HTML_NUMBER; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub HTML_MAXLENGTH { |
31
|
2
|
|
|
2
|
0
|
3116
|
my ($self, $params, $args) = @_; |
32
|
2
|
|
50
|
|
|
10
|
my $data = $params->[0] || ''; |
33
|
2
|
|
|
|
|
4
|
my $maxlength = $args->[0]; |
34
|
|
|
|
|
|
|
|
35
|
2
|
50
|
33
|
|
|
15
|
FormValidator::Simple::Exception->throw( |
36
|
|
|
|
|
|
|
'Validation HTML_MAXLENGTH needs one numeric argument.' |
37
|
|
|
|
|
|
|
) if !defined $maxlength || !Scalar::Util::Numeric::isnum($maxlength); |
38
|
|
|
|
|
|
|
|
39
|
2
|
100
|
|
|
|
14
|
length $data <= $maxlength ? SUCCESS : FAIL; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub HTML_MAX { |
43
|
3
|
|
|
3
|
0
|
375
|
my ($self, $params, $args) = @_; |
44
|
3
|
|
|
|
|
7
|
my $data = $params->[0]; |
45
|
3
|
50
|
|
|
|
10
|
return FAIL if !Scalar::Util::Numeric::isnum($data); |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
7
|
my $max = $args->[0]; |
48
|
3
|
50
|
33
|
|
|
18
|
FormValidator::Simple::Exception->throw( |
49
|
|
|
|
|
|
|
'Validation HTML_MAX needs one numeric argument.' |
50
|
|
|
|
|
|
|
) if !defined $max || !Scalar::Util::Numeric::isnum($max); |
51
|
|
|
|
|
|
|
|
52
|
3
|
100
|
|
|
|
17
|
$data <= $max ? SUCCESS : FAIL; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub HTML_MIN { |
56
|
5
|
|
|
5
|
0
|
534
|
my ($self, $params, $args) = @_; |
57
|
5
|
|
|
|
|
9
|
my $data = $params->[0]; |
58
|
5
|
50
|
|
|
|
19
|
return FAIL if !Scalar::Util::Numeric::isnum($data); |
59
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
9
|
my $min = $args->[0]; |
61
|
5
|
50
|
33
|
|
|
29
|
FormValidator::Simple::Exception->throw( |
62
|
|
|
|
|
|
|
'Validation HTML_MIN needs one numeric argument.' |
63
|
|
|
|
|
|
|
) if !defined $min || !Scalar::Util::Numeric::isnum($min); |
64
|
|
|
|
|
|
|
|
65
|
5
|
100
|
|
|
|
23
|
$data >= $min ? SUCCESS : FAIL; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub HTML_PATTERN { |
69
|
5
|
|
|
5
|
0
|
6357
|
my ($self, $params, $args) = @_; |
70
|
5
|
50
|
|
|
|
15
|
my $data = defined $params->[0] ? $params->[0] : ''; |
71
|
5
|
50
|
|
|
|
13
|
my $pattern = defined $args->[0] ? $args->[0] : ''; |
72
|
|
|
|
|
|
|
|
73
|
5
|
100
|
|
|
|
115
|
$data =~ qr/^(?:$pattern)$/ ? SUCCESS : FAIL; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
!!1; |