| 1 | package Valiemon::Attributes::AnyOf; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use parent qw(Valiemon::Attributes); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use List::MoreUtils qw(any); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Valiemon::Context; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 13 | ▶ | sub attr_name { 'anyOf' } | ||||||||||||||||||||||||||
|
Subroutine
attr_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub is_valid { | ||||||||||||||||||||||||||||
| 15 | 15 | ▶ | my ($class, $context, $schema, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 15 | my $anyOf = $schema->{anyOf}; | |||||||||||||||||||||||||||
| 18 | 15 | ▶ | if (ref $anyOf ne 'ARRAY' || scalar @$anyOf < 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $anyOf ne "ARRAY" or scalar @$anyOf < 1
MC/DC50%1/2
ref $anyOf ne "ARRAY" or scalar @$anyOf < 1
ref $anyOf ne "ARRAY"
scalar @$anyOf < 1
Truth table66%2/3
A or B
A= ref $anyOf ne "ARRAY"B= scalar @$anyOf < 1
| |||||||||||||||||||||||||||||
| 19 | 2 | croak sprintf '`anyOf` must be an array and have at least one element at %s', $context->position | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | $context->in_attr($class, sub { | ||||||||||||||||||||||||||||
| 23 | any { | ||||||||||||||||||||||||||||
| 24 | 19 | ▶ | my $clone_context = Valiemon::Context->clone_from($context); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 19 | $clone_context->sub_validator($_)->validate($data, $clone_context); | |||||||||||||||||||||||||||
| 26 | 13 | ▶ | } @$anyOf; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 13 | }); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | 1; | |||||||||||||||||||||||||||