line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Value::EmailAddress; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
18216
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
476
|
use Moo; |
|
1
|
|
|
|
|
10910
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
1641
|
use namespace::clean; |
|
1
|
|
|
|
|
9432
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
518
|
use MooX::Value::ValidationUtils; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
9
|
1
|
|
|
1
|
|
330
|
use MooX::Value::Domain; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
485
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
extends 'MooX::Value'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _why_invalid |
16
|
|
|
|
|
|
|
{ |
17
|
8
|
|
|
8
|
|
12
|
my ($self, $value) = @_; |
18
|
8
|
100
|
|
|
|
22
|
return ( __PACKAGE__ . ': undefined value', '', undef ) unless defined $value; |
19
|
7
|
100
|
|
|
|
24
|
return ( __PACKAGE__ . ': missing domain', '', undef ) unless $value =~ tr/@//; |
20
|
|
|
|
|
|
|
|
21
|
6
|
|
|
|
|
13
|
my $pos = rindex( $value, '@' ); |
22
|
|
|
|
|
|
|
{ |
23
|
6
|
|
|
|
|
8
|
my $lp = substr( $value, 0, $pos ); |
|
6
|
|
|
|
|
9
|
|
24
|
6
|
|
|
|
|
17
|
my ($why, $long, $data) = MooX::Value::ValidationUtils::why_invalid_email_local_part( $lp ); |
25
|
6
|
50
|
|
|
|
15
|
return ( __PACKAGE__ . ": $why", '', undef ) if defined $why; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
6
|
|
|
|
|
1
|
my $dom = substr( $value, $pos+1 ); |
|
6
|
|
|
|
|
13
|
|
30
|
6
|
|
|
|
|
14
|
my ($why, $long, $data) = MooX::Value::ValidationUtils::why_invalid_domain_name( $dom ); |
31
|
6
|
50
|
|
|
|
17
|
return ( __PACKAGE__ . ": $why", '', $dom ) if defined $why; |
32
|
|
|
|
|
|
|
} |
33
|
6
|
|
|
|
|
12
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub local_part |
37
|
|
|
|
|
|
|
{ |
38
|
2
|
|
|
2
|
1
|
1636
|
my ($self) = @_; |
39
|
2
|
|
|
|
|
16
|
return substr( $self->value, 0, rindex( $self->value, '@' ) ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub domain |
43
|
|
|
|
|
|
|
{ |
44
|
4
|
|
|
4
|
1
|
710
|
my ($self) = @_; |
45
|
4
|
|
|
|
|
117
|
return MooX::Value::Domain->new( substr( $self->value, rindex( $self->value, '@' )+1 ) ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new_canonical |
49
|
|
|
|
|
|
|
{ |
50
|
3
|
|
|
3
|
1
|
5416
|
my ($class, $value) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Canonicalize if possible. If not, let normal validation proceed. |
53
|
3
|
50
|
33
|
|
|
17
|
if( defined $value and $value =~ tr/@// ) |
54
|
|
|
|
|
|
|
{ |
55
|
3
|
|
|
|
|
6
|
my $pos = rindex( $value, '@' ); |
56
|
3
|
|
|
|
|
7
|
my $lp = substr( $value, 0, $pos ); |
57
|
3
|
|
|
|
|
6
|
my $dom = substr( $value, $pos+1 ); |
58
|
3
|
|
|
|
|
4
|
$dom =~ tr/A-Z/a-z/; |
59
|
3
|
|
|
|
|
8
|
$value = "$lp\@$dom"; |
60
|
|
|
|
|
|
|
} |
61
|
3
|
|
|
|
|
75
|
return __PACKAGE__->new( $value ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |