line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Email Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Email; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
41952
|
use strict; |
|
109
|
|
|
|
|
226
|
|
|
109
|
|
|
|
|
2711
|
|
6
|
109
|
|
|
109
|
|
483
|
use warnings; |
|
109
|
|
|
|
|
211
|
|
|
109
|
|
|
|
|
2541
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
494
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
210
|
|
|
109
|
|
|
|
|
8397
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
631
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
227
|
|
|
109
|
|
|
|
|
658
|
|
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 requires a valid email address'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
15
|
|
|
15
|
0
|
42
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
15
|
50
|
33
|
|
|
68
|
if (defined $field->{email} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
15
|
50
|
66
|
|
|
59
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
15
|
|
|
|
|
387
|
my $ere = qr/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[-_a-z0-9][-_a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)$/; |
29
|
|
|
|
|
|
|
|
30
|
15
|
100
|
|
|
|
187
|
$self->error($proto, $field) unless $param =~ $ere; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
15
|
|
|
|
|
42
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |