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