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