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
|
|
43142
|
use strict; |
|
109
|
|
|
|
|
287
|
|
|
109
|
|
|
|
|
2923
|
|
6
|
109
|
|
|
109
|
|
489
|
use warnings; |
|
109
|
|
|
|
|
208
|
|
|
109
|
|
|
|
|
2311
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
465
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
215
|
|
|
109
|
|
|
|
|
8481
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
631
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
214
|
|
|
109
|
|
|
|
|
609
|
|
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 a valid telephone number'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
11
|
|
|
11
|
0
|
22
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
11
|
50
|
33
|
|
|
47
|
if (defined $field->{telephone} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
11
|
50
|
33
|
|
|
35
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
11
|
|
|
|
|
33
|
my $tre = qr/^(?:\+?1)?[-. ]?\(?[2-9][0-8][0-9]\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/; |
29
|
|
|
|
|
|
|
|
30
|
11
|
100
|
|
|
|
102
|
$self->error($proto, $field) unless $param =~ $tre; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
11
|
|
|
|
|
30
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |