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