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
|
108
|
|
|
108
|
|
68819
|
use strict; |
|
108
|
|
|
|
|
220
|
|
|
108
|
|
|
|
|
2753
|
|
6
|
108
|
|
|
108
|
|
543
|
use warnings; |
|
108
|
|
|
|
|
204
|
|
|
108
|
|
|
|
|
2807
|
|
7
|
|
|
|
|
|
|
|
8
|
108
|
|
|
108
|
|
510
|
use base 'Validation::Class::Directive'; |
|
108
|
|
|
|
|
193
|
|
|
108
|
|
|
|
|
7508
|
|
9
|
|
|
|
|
|
|
|
10
|
108
|
|
|
108
|
|
588
|
use Validation::Class::Util; |
|
108
|
|
|
|
|
202
|
|
|
108
|
|
|
|
|
818
|
|
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 a valid postal code'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
19
|
|
|
19
|
0
|
35
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
19
|
50
|
33
|
|
|
105
|
if (defined $field->{zipcode} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
19
|
50
|
33
|
|
|
93
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
19
|
|
|
|
|
63
|
my $zcre = qr/\A\b[0-9]{5}(?:-[0-9]{4})?\b\z/i; |
29
|
19
|
100
|
|
|
|
190
|
$self->error($proto, $field) unless $param =~ $zcre; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
19
|
|
|
|
|
61
|
return $self; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |