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
|
109
|
|
|
109
|
|
46039
|
use strict; |
|
109
|
|
|
|
|
245
|
|
|
109
|
|
|
|
|
2733
|
|
6
|
109
|
|
|
109
|
|
512
|
use warnings; |
|
109
|
|
|
|
|
195
|
|
|
109
|
|
|
|
|
2453
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
485
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
197
|
|
|
109
|
|
|
|
|
9067
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
664
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
215
|
|
|
109
|
|
|
|
|
585
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900058'; # 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
|
7
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
7
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
50
|
33
|
|
|
12
|
if (defined $field->{length} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
6
|
my $length = $field->{length}; |
29
|
|
|
|
|
|
|
|
30
|
3
|
50
|
33
|
|
|
11
|
if ($field->{required} || $param) { |
31
|
|
|
|
|
|
|
|
32
|
3
|
100
|
|
|
|
19
|
unless (length($param) == $length) { |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
9
|
$self->error(@_, $length); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
10
|
return $self; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |