line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Between Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Between; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
53853
|
use strict; |
|
109
|
|
|
|
|
308
|
|
|
109
|
|
|
|
|
3170
|
|
6
|
109
|
|
|
109
|
|
578
|
use warnings; |
|
109
|
|
|
|
|
268
|
|
|
109
|
|
|
|
|
2824
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
600
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
280
|
|
|
109
|
|
|
|
|
10291
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
865
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
257
|
|
|
109
|
|
|
|
|
719
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900059'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'mixin' => 1; |
16
|
|
|
|
|
|
|
has 'field' => 1; |
17
|
|
|
|
|
|
|
has 'multi' => 1; |
18
|
|
|
|
|
|
|
has 'message' => '%s must be between %s'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
21
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
2
|
50
|
33
|
|
|
16
|
if (defined $field->{between} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
6
|
my $between = $field->{between}; |
29
|
|
|
|
|
|
|
|
30
|
2
|
50
|
33
|
|
|
12
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my ( $min, $max ) |
33
|
|
|
|
|
|
|
= isa_arrayref($between) |
34
|
0
|
|
|
|
|
0
|
? @{$between} > 1 |
35
|
2
|
0
|
|
|
|
9
|
? @{$between} |
|
0
|
50
|
|
|
|
0
|
|
36
|
|
|
|
|
|
|
: (split /(?:\s{1,})?\D{1,}(?:\s{1,})?/, $between->[0]) |
37
|
|
|
|
|
|
|
: (split /(?:\s{1,})?\D{1,}(?:\s{1,})?/, $between); |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
6
|
$min = scalar($min); |
40
|
2
|
|
|
|
|
17
|
$max = scalar($max); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# warn $min, ',', $max, ',', $param; |
43
|
|
|
|
|
|
|
|
44
|
2
|
100
|
66
|
|
|
16
|
unless ( $param >= $min && $param <= $max ) { |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
12
|
$self->error(@_, "$min-$max"); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
6
|
return $self; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |