line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Length Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Length; |
4
|
|
|
|
|
|
|
|
5
|
108
|
|
|
108
|
|
66583
|
use strict; |
|
108
|
|
|
|
|
224
|
|
|
108
|
|
|
|
|
2790
|
|
6
|
108
|
|
|
108
|
|
547
|
use warnings; |
|
108
|
|
|
|
|
227
|
|
|
108
|
|
|
|
|
2809
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
545
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
204
|
|
|
108
|
|
|
|
|
7562
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
571
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
232
|
|
|
108
|
|
|
|
|
1133
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900057'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'mixin' => 1; |
16
|
|
|
|
|
|
|
has 'field' => 1; |
17
|
|
|
|
|
|
|
has 'multi' => 0; |
18
|
|
|
|
|
|
|
has 'message' => '%s should be exactly %s characters'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
7
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
50
|
33
|
|
|
21
|
if (defined $field->{length} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
8
|
my $length = $field->{length}; |
29
|
|
|
|
|
|
|
|
30
|
3
|
50
|
33
|
|
|
16
|
if ($field->{required} || $param) { |
31
|
|
|
|
|
|
|
|
32
|
3
|
100
|
|
|
|
12
|
unless (length($param) == $length) { |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
16
|
$self->error(@_, $length); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
9
|
return $self; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |