Valiant/Proxy/Array.pm

filter: Statementstmt 100% 10 / 10 Branchbran 100% 2 / 2 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 2 / 2 Podpod 0.0% 0 / 1 totaltotal 79.1% 19 / 24 CC 4 SCAR 12.4
CC
4
Cov
89%
read_attribute_for_validation
4.1
BEGIN
1.0
CRAP 3.4
« Valiant/Filter/ToArray.pm ↑ Summary Valiant/Filters.pm »
1 package Valiant::Proxy::Array;
2  
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 with 'Valiant::Proxy';
5 37 ▶sub read_attribute_for_validation {
Subroutine read_attribute_for_validation: called CC=4 SCAR=14.0
Pod undocumented
6 37 my ($self, $attribute) = @_;
7 #my $index = $attribute->[-1];
8 37 my (@index) = $attribute=~m/\[(\d+)\]/g;
9 37 ▶ if( @index && $index[-1] =~m/^\d+$/ && defined $self->for->[$index[-1]]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@index and $index[-1] =~ /^\d+$/ and defined $self->for->[$index[-1]]) { } 29 8 37
Condition66%4/6
@index and $index[-1] =~ /^\d+$/ and defined $self->for->[$index[-1]]
!ll&&!rl&&r
8029
@index and $index[-1] =~ /^\d+$/
!ll&&!rl&&r
8029
MC/DC33%1/3
@index and $index[-1] =~ /^\d+$/ and defined $self->for->[$index[-1]]
@index $index[-1] =~ /^\d+$/ defined $self->for->[$index[-1]]
Truth table50%2/4
A and B and C
A= @indexB= $index[-1] =~ /^\d+$/C= defined $self->for->[$index[-1]]
ABCresult
0XX0
10X0
1100
1111
10 29 return $self->for->[$index[-1]];
11 } else {
12 8 return undef; # TODO Might need a flag to allow die here?
13 }
14 }
15  
16 2 1;
17  
18 =head1 NAME
19  
20 Valiant::Proxy::Array - Wrap an arrayref in a result object for validation.
21  
22 =head1 SYNOPSIS
23  
24 my $proxy = Valiant::Proxy::Array->new(
25 validations => [
26 # array elements are addressed by index, e.g. '[0]'
27 [ '[0]' => presence => 1 ],
28 ],
29 );
30  
31 my $result = $proxy->validate([ 'first', 'second' ]);
32  
33 =head1 DESCRIPTION
34  
35 Allows you to run validations against an ArrayRef.
36  
37 You probably won't use this directly, although you can.
38  
39 =head1 SEE ALSO
40  
41 This does the interface defined by L<Valiant::Proxy> so see the docs on that.
42
43 Also: L<Valiant>, L<Valiant::Validator>, L<Valiant::Validator::Each>.
44  
45 =head1 AUTHOR
46
47 See L<Valiant>
48  
49 =head1 COPYRIGHT & LICENSE
50
51 See L<Valiant>
52  
53 =cut
« Valiant/Filter/ToArray.pm ↑ Summary Valiant/Filters.pm »