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
|
108
|
|
|
108
|
|
88646
|
use strict; |
|
108
|
|
|
|
|
238
|
|
|
108
|
|
|
|
|
3248
|
|
6
|
108
|
|
|
108
|
|
606
|
use warnings; |
|
108
|
|
|
|
|
236
|
|
|
108
|
|
|
|
|
3736
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
575
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
284
|
|
|
108
|
|
|
|
|
10575
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
643
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
213
|
|
|
108
|
|
|
|
|
906
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900057'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'mixin' => 1; |
16
|
|
|
|
|
|
|
has 'field' => 1; |
17
|
|
|
|
|
|
|
has 'multi' => 1; |
18
|
|
|
|
|
|
|
has 'message' => '%s must contain between %s characters'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
0
|
11
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
5
|
|
|
|
|
11
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
5
|
50
|
33
|
|
|
35
|
if (defined $field->{between} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
11
|
my $between = $field->{between}; |
29
|
|
|
|
|
|
|
|
30
|
5
|
50
|
66
|
|
|
24
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my ( $min, $max ) |
33
|
|
|
|
|
|
|
= isa_arrayref($between) |
34
|
3
|
|
|
|
|
35
|
? @{$between} > 1 |
35
|
5
|
50
|
|
|
|
19
|
? @{$between} |
|
0
|
100
|
|
|
|
0
|
|
36
|
|
|
|
|
|
|
: (split /(?:\s{1,})?\D{1,}(?:\s{1,})?/, $between->[0]) |
37
|
|
|
|
|
|
|
: (split /(?:\s{1,})?\D{1,}(?:\s{1,})?/, $between); |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
9
|
$min = scalar($min); |
40
|
5
|
|
|
|
|
9
|
$max = scalar($max); |
41
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
12
|
my $value = length($param); |
43
|
|
|
|
|
|
|
|
44
|
5
|
100
|
66
|
|
|
37
|
unless ( $value >= $min && $value <= $max ) { |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
12
|
$self->error(@_, "$min-$max"); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
18
|
return $self; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |