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
|
|
52066
|
use strict; |
|
109
|
|
|
|
|
277
|
|
|
109
|
|
|
|
|
3252
|
|
6
|
109
|
|
|
109
|
|
588
|
use warnings; |
|
109
|
|
|
|
|
305
|
|
|
109
|
|
|
|
|
2968
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
596
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
239
|
|
|
109
|
|
|
|
|
10276
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
804
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
295
|
|
|
109
|
|
|
|
|
692
|
|
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 requires a valid email address'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
15
|
|
|
15
|
0
|
40
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
15
|
50
|
33
|
|
|
84
|
if (defined $field->{email} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
15
|
50
|
66
|
|
|
63
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
15
|
|
|
|
|
426
|
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
|
|
|
|
183
|
$self->error($proto, $field) unless $param =~ $ere; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
15
|
|
|
|
|
51
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |