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
|
|
53706
|
use strict; |
|
109
|
|
|
|
|
309
|
|
|
109
|
|
|
|
|
3217
|
|
6
|
109
|
|
|
109
|
|
593
|
use warnings; |
|
109
|
|
|
|
|
284
|
|
|
109
|
|
|
|
|
2856
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
652
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
259
|
|
|
109
|
|
|
|
|
10260
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
797
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
280
|
|
|
109
|
|
|
|
|
720
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900059'; # 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
|
8
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
7
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
50
|
33
|
|
|
17
|
if (defined $field->{length} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
6
|
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__ |