line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Zipcode Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Zipcode; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
53137
|
use strict; |
|
109
|
|
|
|
|
279
|
|
|
109
|
|
|
|
|
3085
|
|
6
|
109
|
|
|
109
|
|
623
|
use warnings; |
|
109
|
|
|
|
|
271
|
|
|
109
|
|
|
|
|
2840
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
621
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
274
|
|
|
109
|
|
|
|
|
10723
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
791
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
284
|
|
|
109
|
|
|
|
|
743
|
|
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 is not a valid postal code'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
19
|
|
|
19
|
0
|
63
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
19
|
50
|
33
|
|
|
104
|
if (defined $field->{zipcode} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
19
|
50
|
33
|
|
|
93
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
19
|
|
|
|
|
83
|
my $zcre = qr/\A\b[0-9]{5}(?:-[0-9]{4})?\b\z/i; |
29
|
19
|
100
|
|
|
|
326
|
$self->error($proto, $field) unless $param =~ $zcre; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
19
|
|
|
|
|
62
|
return $self; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |