line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Biblio::SICI::Role::ValidSegment; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Biblio::SICI::Role::ValidSegment::VERSION = '0.04'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Role to provide common validation error handling functionality to the segments |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
48933
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
124
|
|
9
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
98
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
17
|
use Moo::Role; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
21
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has validationErrors => ( is => 'lazy', ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _build_validationErrors { |
17
|
6
|
|
|
6
|
|
882
|
return {}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub log_problem_on { |
22
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $attr, $desc ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
0
|
|
|
0
|
if ( defined($attr) and $attr and defined($desc) and $desc ) { |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$self->validationErrors->{$attr} = $desc; |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
0
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub clear_problem_on { |
32
|
1262
|
|
|
1262
|
1
|
2001
|
my ( $self, $attr ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
1262
|
50
|
|
|
|
3347
|
delete $self->validationErrors->{$attr} if exists $self->validationErrors->{$attr}; |
35
|
1262
|
|
|
|
|
38770
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub list_problems { |
40
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
41
|
0
|
|
|
|
|
0
|
return %{ $self->validationErrors }; |
|
0
|
|
|
|
|
0
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub is_valid { |
46
|
363
|
|
|
363
|
1
|
2316
|
my $self = shift; |
47
|
363
|
|
|
|
|
421
|
my $invalid = 0; |
48
|
|
|
|
|
|
|
|
49
|
363
|
|
|
|
|
359
|
my %problems = %{ $self->validationErrors }; |
|
363
|
|
|
|
|
866
|
|
50
|
|
|
|
|
|
|
|
51
|
363
|
|
|
|
|
9698
|
foreach my $attr ( keys %problems ) { |
52
|
0
|
0
|
0
|
|
|
0
|
if ( exists $problems{$attr} and defined $problems{$attr} and $problems{$attr} ne '' ) { |
|
|
|
0
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
$invalid++; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
363
|
50
|
|
|
|
786
|
return 0 if $invalid; |
57
|
363
|
|
|
|
|
1090
|
return 1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |