line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: MinDigits Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::MinDigits; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
54078
|
use strict; |
|
109
|
|
|
|
|
310
|
|
|
109
|
|
|
|
|
3168
|
|
6
|
109
|
|
|
109
|
|
588
|
use warnings; |
|
109
|
|
|
|
|
334
|
|
|
109
|
|
|
|
|
2830
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
611
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
258
|
|
|
109
|
|
|
|
|
10455
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
802
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
268
|
|
|
109
|
|
|
|
|
728
|
|
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 must not contain less than %s digits'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
0
|
9
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
10
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
33
|
|
|
21
|
if (defined $field->{min_digits} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
8
|
my $min_digits = $field->{min_digits}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
33
|
|
|
19
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
32
|
my @i = ($param =~ /[0-9]/g); |
33
|
|
|
|
|
|
|
|
34
|
4
|
100
|
|
|
|
25
|
if (@i < $min_digits) { |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
11
|
$self->error(@_, $min_digits); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
14
|
return $self; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |