line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: MaxSymbols Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::MaxSymbols; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
54086
|
use strict; |
|
109
|
|
|
|
|
315
|
|
|
109
|
|
|
|
|
3086
|
|
6
|
109
|
|
|
109
|
|
594
|
use warnings; |
|
109
|
|
|
|
|
1916
|
|
|
109
|
|
|
|
|
3014
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
2151
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
341
|
|
|
109
|
|
|
|
|
12135
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
839
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
267
|
|
|
109
|
|
|
|
|
792
|
|
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 more than %s special characters'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
0
|
9
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
9
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
33
|
|
|
20
|
if (defined $field->{max_symbols} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
9
|
my $max_symbols = $field->{max_symbols}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
33
|
|
|
19
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
26
|
my @i = ($param =~ /[^a-zA-Z0-9]/g); |
33
|
|
|
|
|
|
|
|
34
|
4
|
100
|
|
|
|
16
|
if (@i > $max_symbols) { |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
17
|
$self->error(@_, $max_symbols); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
12
|
return $self; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |