line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Braintree::ValidationErrorCollection; |
2
|
|
|
|
|
|
|
$WebService::Braintree::ValidationErrorCollection::VERSION = '0.94'; |
3
|
20
|
|
|
20
|
|
299
|
use 5.010_001; |
|
20
|
|
|
|
|
66
|
|
4
|
20
|
|
|
20
|
|
99
|
use strictures 1; |
|
20
|
|
|
|
|
129
|
|
|
20
|
|
|
|
|
693
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
WebService::Braintree::ValidationError |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 PURPOSE |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This class represents a collection of validation errors. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
20
|
|
|
20
|
|
1780
|
use Moose; |
|
20
|
|
|
|
|
39
|
|
|
20
|
|
|
|
|
118
|
|
17
|
20
|
|
|
20
|
|
124516
|
use WebService::Braintree::ValidationError; |
|
20
|
|
|
|
|
64
|
|
|
20
|
|
|
|
|
6676
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 CLASS METHODS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This class is B<NOT> an interface, so it does B<NOT> have any class methods. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub BUILD { |
30
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$self->{_errors} = [ map { WebService::Braintree::ValidationError->new($_) } @{$args->{errors}} ]; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$self->{_nested} = {}; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
while (my ($key, $value) = each %$args) { |
36
|
0
|
0
|
|
|
|
|
next if $key eq 'errors'; |
37
|
0
|
|
|
|
|
|
$self->{_nested}->{$key} = __PACKAGE__->new($value); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 deep_errors() |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
This returns a list of the errors for the underlying validation failures. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'deep_errors' => (is => 'ro', lazy => 1, builder => '_deep_errors'); |
48
|
|
|
|
|
|
|
sub _deep_errors { |
49
|
0
|
|
|
0
|
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my @nested = map { @{$_->deep_errors} } values %{$self->{_nested}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return [ @{$self->{_errors}}, @nested ]; |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 for() |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This takes a target and returns a ValidationErrorCollection for that value (if |
57
|
|
|
|
|
|
|
it exists). |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub for { |
62
|
0
|
|
|
0
|
1
|
|
my ($self, $target) = @_; |
63
|
0
|
|
|
|
|
|
return $self->{_nested}->{$target}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 on() |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This takes an attribute and returns an arrayref of the L<ValidationErrors|WebService::Braintree::ValidationError/> for that attribute. If there aren't any, then |
69
|
|
|
|
|
|
|
this will return an empty arrayref. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub on { |
74
|
0
|
|
|
0
|
1
|
|
my ($self, $attribute) = @_; |
75
|
0
|
|
|
|
|
|
return [ grep { $_->attribute eq $attribute } @{$self->{_errors}} ] |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 TODO |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item Need to document what the attributes actually mean. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |