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
|
109
|
|
|
109
|
|
42696
|
use strict; |
|
109
|
|
|
|
|
231
|
|
|
109
|
|
|
|
|
2723
|
|
6
|
109
|
|
|
109
|
|
481
|
use warnings; |
|
109
|
|
|
|
|
215
|
|
|
109
|
|
|
|
|
2324
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
455
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
200
|
|
|
109
|
|
|
|
|
8645
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
637
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
220
|
|
|
109
|
|
|
|
|
557
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900058'; # 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
|
70
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
25
|
50
|
33
|
|
|
148
|
if (defined $field->{pattern} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
25
|
|
|
|
|
51
|
my $pattern = $field->{pattern}; |
27
|
|
|
|
|
|
|
|
28
|
25
|
50
|
66
|
|
|
91
|
if ($field->{required} || $param) { |
29
|
|
|
|
|
|
|
|
30
|
25
|
100
|
|
|
|
87
|
unless ( isa_regexp($pattern) ) { |
31
|
|
|
|
|
|
|
|
32
|
10
|
|
|
|
|
56
|
$pattern =~ s/([^#X ])/\\$1/g; |
33
|
10
|
|
|
|
|
50
|
$pattern =~ s/#/\\d/g; |
34
|
10
|
|
|
|
|
28
|
$pattern =~ s/X/[a-zA-Z]/g; |
35
|
10
|
|
|
|
|
91
|
$pattern = qr/$pattern/; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
25
|
100
|
|
|
|
513
|
unless ( $param =~ $pattern ) { |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
55
|
$self->error($proto, $field); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
25
|
|
|
|
|
75
|
return $self; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |