line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Lite::Constraint::Time; |
2
|
2
|
|
|
2
|
|
1114
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
38
|
|
4
|
2
|
|
|
2
|
|
8
|
use FormValidator::Lite::Constraint; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
rule 'TIME' => sub { |
7
|
|
|
|
|
|
|
if ( ref $_) { |
8
|
|
|
|
|
|
|
# query: h=12&m=00&d=60 |
9
|
|
|
|
|
|
|
# rule: {time => [qw/h m s/]} => ['TIME'] |
10
|
|
|
|
|
|
|
_v(@{$_}); |
11
|
|
|
|
|
|
|
} else { |
12
|
|
|
|
|
|
|
# query: time=12:00:30 |
13
|
|
|
|
|
|
|
# rule: time => ['time'] |
14
|
|
|
|
|
|
|
_v(split /:/, $_); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _v { |
19
|
6
|
|
|
6
|
|
10
|
my ($h, $m, $s) = @_; |
20
|
|
|
|
|
|
|
|
21
|
6
|
100
|
100
|
|
|
26
|
return 0 if (!defined($h) or !defined($m)); |
22
|
4
|
100
|
66
|
|
|
15
|
return 0 if ("$h" eq "" or "$m" eq ""); |
23
|
3
|
|
100
|
|
|
10
|
$s ||= 0; # optional |
24
|
|
|
|
|
|
|
|
25
|
3
|
50
|
66
|
|
|
23
|
if ( $h > 23 or $h < 0 or $m > 59 or $m < 0 or $s > 59 or $s < 0 ) { |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
8
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
__END__ |