line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: MaxLength Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::MaxLength; |
4
|
|
|
|
|
|
|
|
5
|
108
|
|
|
108
|
|
68392
|
use strict; |
|
108
|
|
|
|
|
217
|
|
|
108
|
|
|
|
|
2844
|
|
6
|
108
|
|
|
108
|
|
636
|
use warnings; |
|
108
|
|
|
|
|
208
|
|
|
108
|
|
|
|
|
2985
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
550
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
186
|
|
|
108
|
|
|
|
|
7718
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
577
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
197
|
|
|
108
|
|
|
|
|
690
|
|
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 must not contain more than %s characters'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
56
|
|
|
56
|
0
|
102
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
56
|
|
|
|
|
102
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
56
|
100
|
66
|
|
|
337
|
if (defined $field->{max_length} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
52
|
|
|
|
|
92
|
my $max_length = $field->{max_length}; |
29
|
|
|
|
|
|
|
|
30
|
52
|
50
|
66
|
|
|
254
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
52
|
100
|
|
|
|
163
|
if (length($param) > $max_length) { |
33
|
|
|
|
|
|
|
|
34
|
6
|
|
|
|
|
49
|
$self->error(@_, $max_length); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
56
|
|
|
|
|
172
|
return $self; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |