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