line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Value::EmailAddressCommon; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19070
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
476
|
use Moo; |
|
1
|
|
|
|
|
11005
|
|
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
1693
|
use namespace::clean; |
|
1
|
|
|
|
|
9123
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
542
|
use MooX::Value::ValidationUtils; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
9
|
1
|
|
|
1
|
|
328
|
use MooX::Value::Domain; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
429
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
extends 'MooX::Value'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _why_invalid |
16
|
|
|
|
|
|
|
{ |
17
|
8
|
|
|
8
|
|
8
|
my ($self, $value) = @_; |
18
|
8
|
100
|
|
|
|
19
|
return ( __PACKAGE__ . ': undefined value', '', undef ) unless defined $value; |
19
|
7
|
100
|
|
|
|
21
|
return ( __PACKAGE__ . ': missing domain', '', undef ) unless $value =~ tr/@//; |
20
|
|
|
|
|
|
|
|
21
|
6
|
|
|
|
|
10
|
my $pos = rindex( $value, '@' ); |
22
|
|
|
|
|
|
|
{ |
23
|
6
|
|
|
|
|
7
|
my $lp = substr( $value, 0, $pos ); |
|
6
|
|
|
|
|
19
|
|
24
|
6
|
|
|
|
|
17
|
my ($why, $long, $data) = MooX::Value::ValidationUtils::why_invalid_common_email_local_part( $lp ); |
25
|
6
|
100
|
|
|
|
20
|
return ( __PACKAGE__ . ": $why", '', undef ) if defined $why; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
4
|
|
|
|
|
5
|
my $dom = substr( $value, $pos+1 ); |
|
4
|
|
|
|
|
7
|
|
30
|
4
|
|
|
|
|
11
|
my ($why, $long, $data) = MooX::Value::ValidationUtils::why_invalid_domain_name( $dom ); |
31
|
4
|
50
|
|
|
|
10
|
return ( __PACKAGE__ . ": $why", '', $dom ) if defined $why; |
32
|
|
|
|
|
|
|
} |
33
|
4
|
|
|
|
|
7
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub local_part |
37
|
|
|
|
|
|
|
{ |
38
|
1
|
|
|
1
|
1
|
546
|
my ($self) = @_; |
39
|
1
|
|
|
|
|
9
|
return substr( $self->value, 0, rindex( $self->value, '@' ) ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub domain |
43
|
|
|
|
|
|
|
{ |
44
|
2
|
|
|
2
|
1
|
249
|
my ($self) = @_; |
45
|
2
|
|
|
|
|
52
|
return MooX::Value::Domain->new( substr( $self->value, rindex( $self->value, '@' )+1 ) ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new_canonical |
49
|
|
|
|
|
|
|
{ |
50
|
3
|
|
|
3
|
1
|
2572
|
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
|
|
|
|
|
5
|
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
|
|
|
|
|
7
|
$value = "$lp\@$dom"; |
60
|
|
|
|
|
|
|
} |
61
|
3
|
|
|
|
|
67
|
return __PACKAGE__->new( $value ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |