line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: MaxDigits Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::MaxDigits; |
4
|
|
|
|
|
|
|
|
5
|
108
|
|
|
108
|
|
68717
|
use strict; |
|
108
|
|
|
|
|
215
|
|
|
108
|
|
|
|
|
2780
|
|
6
|
108
|
|
|
108
|
|
541
|
use warnings; |
|
108
|
|
|
|
|
215
|
|
|
108
|
|
|
|
|
2910
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
538
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
196
|
|
|
108
|
|
|
|
|
7731
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
696
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
215
|
|
|
108
|
|
|
|
|
712
|
|
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 digits'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
0
|
7
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
8
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
33
|
|
|
25
|
if (defined $field->{max_digits} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
13
|
my $max_digits = $field->{max_digits}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
33
|
|
|
22
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
25
|
my @i = ($param =~ /[0-9]/g); |
33
|
|
|
|
|
|
|
|
34
|
4
|
100
|
|
|
|
14
|
if (@i > $max_digits) { |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
13
|
$self->error(@_, $max_digits); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
13
|
return $self; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |