line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Pattern Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Pattern; |
4
|
|
|
|
|
|
|
|
5
|
108
|
|
|
108
|
|
68559
|
use strict; |
|
108
|
|
|
|
|
226
|
|
|
108
|
|
|
|
|
2732
|
|
6
|
108
|
|
|
108
|
|
538
|
use warnings; |
|
108
|
|
|
|
|
210
|
|
|
108
|
|
|
|
|
2879
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
595
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
200
|
|
|
108
|
|
|
|
|
7689
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
597
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
229
|
|
|
108
|
|
|
|
|
749
|
|
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 is not formatted properly'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
25
|
|
|
25
|
0
|
93
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
25
|
50
|
33
|
|
|
161
|
if (defined $field->{pattern} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
25
|
|
|
|
|
54
|
my $pattern = $field->{pattern}; |
27
|
|
|
|
|
|
|
|
28
|
25
|
50
|
66
|
|
|
155
|
if ($field->{required} || $param) { |
29
|
|
|
|
|
|
|
|
30
|
25
|
100
|
|
|
|
93
|
unless ( isa_regexp($pattern) ) { |
31
|
|
|
|
|
|
|
|
32
|
10
|
|
|
|
|
81
|
$pattern =~ s/([^#X ])/\\$1/g; |
33
|
10
|
|
|
|
|
59
|
$pattern =~ s/#/\\d/g; |
34
|
10
|
|
|
|
|
29
|
$pattern =~ s/X/[a-zA-Z]/g; |
35
|
10
|
|
|
|
|
112
|
$pattern = qr/$pattern/; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
25
|
100
|
|
|
|
222
|
unless ( $param =~ $pattern ) { |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
58
|
$self->error($proto, $field); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
25
|
|
|
|
|
85
|
return $self; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |