blib/lib/Valiemon/Attributes/OneOf.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 2 totaltotal 92.1% 47 / 51 CC 3 SCAR 3.8
CC
3
Cov
97%
is_valid
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« blib/lib/Valiemon/Attributes/AnyOf.pm ↑ Summary blib/lib/Valiemon/Attributes/Maximum.pm »
1 package Valiemon::Attributes::OneOf;
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(one);
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 { 'oneOf' }
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 $oneOf = $schema->{oneOf};
18 15 ▶ if (ref $oneOf ne 'ARRAY' || scalar @$oneOf < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oneOf ne "ARRAY" or scalar @$oneOf < 1) 2 13 15
Condition66%2/3
ref $oneOf ne "ARRAY" or scalar @$oneOf < 1
l!l&&r!l&&!r
2013
MC/DC50%1/2
ref $oneOf ne "ARRAY" or scalar @$oneOf < 1
ref $oneOf ne "ARRAY" scalar @$oneOf < 1
Truth table66%2/3
A or B
A= ref $oneOf ne "ARRAY"B= scalar @$oneOf < 1
ABresult
1X1
011
000
19 2 croak sprintf '`oneOf` must be an array and have at least one element at %s', $context->position
20 }
21  
22 $context->in_attr($class, sub {
23 one {
24 24 ▶ my $clone_context = Valiemon::Context->clone_from($context);
Subroutine __ANON__: called CC=1 SCAR=0.0
25 24 $clone_context->sub_validator($_)->validate($data, $clone_context);
26 13 ▶ } @$oneOf;
Subroutine __ANON__: called CC=1 SCAR=0.0
27 13 });
28 }
29  
30 2 1;
« blib/lib/Valiemon/Attributes/AnyOf.pm ↑ Summary blib/lib/Valiemon/Attributes/Maximum.pm »