line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Lite::Constraint::Time; |
2
|
2
|
|
|
2
|
|
1031
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
48
|
|
3
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
39
|
|
4
|
2
|
|
|
2
|
|
7
|
use FormValidator::Lite::Constraint; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
9
|
|
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
|
|
6
|
my ($h, $m, $s) = @_; |
20
|
|
|
|
|
|
|
|
21
|
6
|
100
|
66
|
|
|
18
|
return 0 if (!defined($h) or !defined($m)); |
22
|
4
|
100
|
66
|
|
|
16
|
return 0 if ("$h" eq "" or "$m" eq ""); |
23
|
3
|
|
100
|
|
|
8
|
$s ||= 0; # optional |
24
|
|
|
|
|
|
|
|
25
|
3
|
50
|
66
|
|
|
29
|
if ( $h > 23 or $h < 0 or $m > 59 or $m < 0 or $s > 59 or $s < 0 ) { |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
26
|
1
|
|
|
|
|
3
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
6
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
__END__ |