line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Telephone Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Telephone; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
52742
|
use strict; |
|
109
|
|
|
|
|
285
|
|
|
109
|
|
|
|
|
3185
|
|
6
|
109
|
|
|
109
|
|
628
|
use warnings; |
|
109
|
|
|
|
|
243
|
|
|
109
|
|
|
|
|
2994
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
579
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
302
|
|
|
109
|
|
|
|
|
10285
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
764
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
276
|
|
|
109
|
|
|
|
|
731
|
|
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 telephone number'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
11
|
|
|
11
|
0
|
42
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
11
|
50
|
33
|
|
|
76
|
if (defined $field->{telephone} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
11
|
50
|
33
|
|
|
51
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
11
|
|
|
|
|
45
|
my $tre = qr/^(?:\+?1)?[-. ]?\(?[2-9][0-8][0-9]\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/; |
29
|
|
|
|
|
|
|
|
30
|
11
|
100
|
|
|
|
160
|
$self->error($proto, $field) unless $param =~ $tre; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
11
|
|
|
|
|
34
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |