| 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 | 108 |  |  | 108 |  | 68918 | use strict; | 
|  | 108 |  |  |  |  | 204 |  | 
|  | 108 |  |  |  |  | 3028 |  | 
| 6 | 108 |  |  | 108 |  | 526 | use warnings; | 
|  | 108 |  |  |  |  | 197 |  | 
|  | 108 |  |  |  |  | 2933 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 108 |  |  | 108 |  | 561 | use base 'Validation::Class::Directive'; | 
|  | 108 |  |  |  |  | 209 |  | 
|  | 108 |  |  |  |  | 7972 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 108 |  |  | 108 |  | 598 | use Validation::Class::Util; | 
|  | 108 |  |  |  |  | 241 |  | 
|  | 108 |  |  |  |  | 786 |  | 
| 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 telephone number'; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | sub validate { | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 11 |  |  | 11 | 0 | 28 | my ($self, $proto, $field, $param) = @_; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 11 | 50 | 33 |  |  | 70 | if (defined $field->{telephone} && defined $param) { | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 11 | 50 | 33 |  |  | 59 | 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 |  |  |  |  | 38 | return $self; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | 1; | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | __END__ |