line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1449
|
use 5.008; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
42
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Class::Value::Contact::Name::Full; |
6
|
|
|
|
|
|
|
our $VERSION = '1.100840'; |
7
|
|
|
|
|
|
|
# ABSTRACT: Contact-related value objects |
8
|
1
|
|
|
1
|
|
5
|
use parent 'Class::Value::Contact'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# A name is well-formed if it consists of 2-5 whitespace-separated words, at |
11
|
|
|
|
|
|
|
# least two of which must contain at least two [A-Za-z] characters. This is |
12
|
|
|
|
|
|
|
# rather arbitrary; if you allow different forms of names, subclass this |
13
|
|
|
|
|
|
|
# class. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# Note that we don't check whether the string only consists of valid |
16
|
|
|
|
|
|
|
# characters - that's handled by the charset handler mechanism in |
17
|
|
|
|
|
|
|
# Class::Value::String (i.e., when checking for the validity of the value - |
18
|
|
|
|
|
|
|
# here we check for well-formedness). |
19
|
|
|
|
|
|
|
sub is_well_formed_value { |
20
|
2
|
|
|
2
|
1
|
2700
|
my ($self, $value) = @_; |
21
|
2
|
50
|
33
|
|
|
15
|
return 1 unless defined($value) && length($value); |
22
|
2
|
50
|
|
|
|
13
|
return 0 unless $self->SUPER::is_well_formed_value($value); |
23
|
2
|
|
|
|
|
10
|
local $_ = $value; |
24
|
2
|
|
|
|
|
6
|
my @words = split /\s+/; |
25
|
2
|
100
|
66
|
|
|
16
|
return 0 if @words < 2 || @words > 5; |
26
|
1
|
|
|
|
|
2
|
my $valid_words = 0; |
27
|
1
|
|
|
|
|
3
|
for (@words) { |
28
|
2
|
50
|
|
|
|
30
|
$valid_words++ if 2 <= (() = /[A-Za-z]/g); |
29
|
|
|
|
|
|
|
} |
30
|
1
|
|
|
|
|
6
|
return $valid_words >= 2; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub send_notify_value_not_wellformed { |
34
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
35
|
0
|
|
|
|
|
|
local $Error::Depth = $Error::Depth + 2; |
36
|
0
|
|
|
|
|
|
$self->exception_container->record( |
37
|
|
|
|
|
|
|
'Class::Value::Contact::Exception::Name::NotWellformed', |
38
|
|
|
|
|
|
|
name => $value,); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub send_notify_value_invalid { |
42
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
43
|
0
|
|
|
|
|
|
local $Error::Depth = $Error::Depth + 2; |
44
|
0
|
|
|
|
|
|
$self->exception_container->record( |
45
|
|
|
|
|
|
|
'Class::Value::Contact::Exception::Name::Invalid', |
46
|
|
|
|
|
|
|
name => $value,); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |