line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Simple::Struct::Regex; |
2
|
11
|
|
|
11
|
|
19143
|
use 5.008_001; |
|
11
|
|
|
|
|
35
|
|
|
11
|
|
|
|
|
417
|
|
3
|
11
|
|
|
11
|
|
56
|
use strict; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
443
|
|
4
|
11
|
|
|
11
|
|
58
|
use warnings; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
282
|
|
5
|
11
|
|
|
11
|
|
11108
|
use Email::Valid; |
|
11
|
|
|
|
|
2092955
|
|
|
11
|
|
|
|
|
409
|
|
6
|
11
|
|
|
11
|
|
10973
|
use Time::Piece; |
|
11
|
|
|
|
|
171335
|
|
|
11
|
|
|
|
|
71
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
9
|
|
|
|
|
|
|
|
10
|
11
|
|
|
11
|
|
1121
|
use base 'Exporter'; |
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
11959
|
|
11
|
|
|
|
|
|
|
our @EXPORT= qw/NOT_BLANK INT ASCII STRING DECIMAL EMAIL DATETIME DATE TIME TINYINT URL LENGTH BETWEEN DIGIT_LENGTH/; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub NOT_BLANK{ |
14
|
72
|
|
|
72
|
0
|
111
|
my $s = shift; |
15
|
72
|
100
|
100
|
|
|
365
|
if (defined $s and length($s) > 0 ){ |
16
|
65
|
|
|
|
|
293
|
return 1; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
7
|
|
|
|
|
36
|
!!$s; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub INT{ |
23
|
104
|
|
|
104
|
1
|
192
|
my $s = shift; |
24
|
104
|
100
|
|
|
|
229
|
return 1 unless $s; |
25
|
102
|
|
|
|
|
865
|
$s =~ m/^\d+$|^-\d+$/; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub ASCII{ |
29
|
57
|
|
|
57
|
1
|
88
|
my $s = shift; |
30
|
57
|
100
|
|
|
|
170
|
return 1 unless $s; |
31
|
48
|
|
|
|
|
416
|
$s =~ /^[\x21-\x7E]+$/; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub STRING{ |
35
|
0
|
|
|
0
|
1
|
0
|
my $s = shift; |
36
|
0
|
0
|
|
|
|
0
|
return 1 unless $s; |
37
|
0
|
|
|
|
|
0
|
1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub DECIMAL{ |
41
|
14
|
|
|
14
|
1
|
51
|
my $s = shift; |
42
|
14
|
50
|
|
|
|
32
|
return 1 unless $s; |
43
|
14
|
100
|
|
|
|
126
|
$s =~ m/^\d+\.\d+$|^-\d+\.\d+$/ or INT($s); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub EMAIL{ |
47
|
0
|
|
|
0
|
1
|
0
|
my $s = shift; |
48
|
0
|
0
|
|
|
|
0
|
return 1 unless $s; |
49
|
0
|
|
|
|
|
0
|
Email::Valid->address(-address => $s); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub DATETIME{ |
53
|
7
|
|
|
7
|
1
|
13
|
my $s = shift; |
54
|
7
|
50
|
|
|
|
19
|
return 1 unless $s; |
55
|
7
|
|
|
|
|
73
|
eval{ |
56
|
7
|
|
|
|
|
29
|
Time::Piece->strptime($s , "%Y-%m-%d %H:%M:%S"); |
57
|
|
|
|
|
|
|
}; |
58
|
7
|
100
|
|
|
|
156
|
if($@){ |
59
|
6
|
|
|
|
|
8
|
eval{ |
60
|
6
|
|
|
|
|
32
|
Time::Piece->strptime($s , "%Y/%m/%d %H:%M:%S"); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
7
|
100
|
|
|
|
81
|
if($@){ |
64
|
5
|
|
|
|
|
6
|
eval{ |
65
|
5
|
|
|
|
|
13
|
Time::Piece->strptime($s , "%Y-%m-%d %H-%M-%S"); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
7
|
100
|
|
|
|
64
|
if($@){ |
69
|
4
|
|
|
|
|
5
|
eval{ |
70
|
4
|
|
|
|
|
11
|
Time::Piece->strptime($s , "%Y/%m/%d %H-%M-%S"); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
7
|
|
|
|
|
78
|
!$@ |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub DATE{ |
77
|
5
|
|
|
5
|
1
|
10
|
my $s = shift; |
78
|
5
|
50
|
|
|
|
12
|
return 1 unless $s; |
79
|
5
|
|
|
|
|
7
|
eval{ |
80
|
5
|
|
|
|
|
15
|
Time::Piece->strptime($s , "%Y-%m-%d"); |
81
|
|
|
|
|
|
|
}; |
82
|
5
|
100
|
|
|
|
83
|
if($@){ |
83
|
3
|
|
|
|
|
5
|
eval{ |
84
|
3
|
|
|
|
|
9
|
Time::Piece->strptime($s , "%Y/%m/%d"); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
5
|
100
|
|
|
|
71
|
if($@){ |
88
|
1
|
|
|
|
|
3
|
eval{ |
89
|
1
|
|
|
|
|
4
|
Time::Piece->strptime($s , "%Y-%m-%d"); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
5
|
100
|
|
|
|
16
|
if($@){ |
93
|
1
|
|
|
|
|
2
|
eval{ |
94
|
1
|
|
|
|
|
4
|
Time::Piece->strptime($s , "%Y/%m/%d"); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
5
|
|
|
|
|
29
|
!$@ |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub TIME{ |
101
|
5
|
|
|
5
|
1
|
10
|
my $s = shift; |
102
|
5
|
50
|
|
|
|
11
|
return 1 unless $s; |
103
|
5
|
|
|
|
|
40
|
$s =~ m/\d{2}-\d{2}-\d{2}|\d{2}:\d{2}:\d{2}/; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub TINYINT{ |
107
|
11
|
|
|
11
|
0
|
20
|
my $s = shift; |
108
|
11
|
100
|
|
|
|
27
|
return 1 unless $s; |
109
|
9
|
|
66
|
|
|
65
|
return ($s eq "0" or $s eq "1"); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub LENGTH{ |
113
|
9
|
|
|
9
|
1
|
15
|
my ($s , $min , $max) = @_; |
114
|
9
|
|
|
|
|
24
|
my $len = length($s); |
115
|
9
|
100
|
100
|
|
|
62
|
if($len == 0 or $len >= $min and $len <= $max){ |
|
|
|
66
|
|
|
|
|
116
|
5
|
|
|
|
|
37
|
return 1; |
117
|
|
|
|
|
|
|
}else{ |
118
|
4
|
|
|
|
|
16
|
return 0; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub DIGIT_LENGTH{ |
123
|
3
|
|
|
3
|
0
|
5
|
my ($s , $integer , $decimal) = @_; |
124
|
3
|
|
|
|
|
19
|
my ($integer_value , $decimal_value) = $s =~ m/(\d+)\.(\d+)/; |
125
|
|
|
|
|
|
|
|
126
|
3
|
100
|
100
|
|
|
14
|
if(length($integer_value) <= $integer && length($decimal_value) <= $decimal){ |
127
|
1
|
|
|
|
|
9
|
return 1; |
128
|
|
|
|
|
|
|
}else{ |
129
|
2
|
|
|
|
|
9
|
return 0; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub BETWEEN{ |
134
|
9
|
|
|
9
|
1
|
12
|
my ($s , $min , $max) = @_; |
135
|
9
|
100
|
100
|
|
|
38
|
if($s >= $min and $s <= $max){ |
136
|
4
|
|
|
|
|
31
|
return 1; |
137
|
|
|
|
|
|
|
}else{ |
138
|
5
|
|
|
|
|
19
|
return 0; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub URL{ |
143
|
7
|
|
|
7
|
1
|
40
|
my ($s) = @_; |
144
|
7
|
50
|
|
|
|
21
|
return 1 unless $s; |
145
|
7
|
|
|
|
|
42
|
$s =~ m/^http:\/\/|^https:\/\//; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
149
|
|
|
|
|
|
|
__END__ |