| 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
Condition66%4/6
@index and $index[-1] =~ /^\d+$/ and defined $self->for->[$index[-1]]
@index and $index[-1] =~ /^\d+$/
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]]
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||