line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Lite::Constraint::Time; |
2
|
2
|
|
|
2
|
|
1302
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
75
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
55
|
|
4
|
2
|
|
|
2
|
|
8
|
use FormValidator::Lite::Constraint; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
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
|
|
|
21
|
return 0 if (!defined($h) or !defined($m)); |
22
|
4
|
100
|
66
|
|
|
18
|
return 0 if ("$h" eq "" or "$m" eq ""); |
23
|
3
|
|
100
|
|
|
9
|
$s ||= 0; # optional |
24
|
|
|
|
|
|
|
|
25
|
3
|
50
|
66
|
|
|
35
|
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
|
|
|
|
|
9
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
__END__ |