blib/lib/Valiemon/Attributes/MaxLength.pm

filter: Statementstmt 100% 24 / 24 Branchbran 75.0% 3 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 93.0% 40 / 43 CC 4 SCAR 5.5
CC
4
Cov
97%
__ANON__
3.0
is_valid
2.0
BEGIN
1.0
CRAP 1.7
« blib/lib/Valiemon/Attributes/MinItems.pm ↑ Summary blib/lib/Valiemon/Attributes/MinLength.pm »
1 package Valiemon::Attributes::MaxLength;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use parent qw(Valiemon::Attributes);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 21 ▶sub attr_name { 'maxLength' }
Subroutine attr_name: called CC=1 SCAR=0.0
Pod undocumented
10  
11 sub is_valid {
12 21 ▶ my ($class, $context, $schema, $data) = @_;
Subroutine is_valid: called CC=2 SCAR=6.9
Pod undocumented
13  
14 21 ▶ return 1 unless $context->prims->is_string($data); # ignore
Branch: 1 branch
BranchTrueFalseTotal
unless $context->prims->is_string($data) 0 21 21
15  
16 21 my $max_length = $schema->{maxLength};
17 $context->in_attr($class, sub {
18 21 ▶ if (!$context->prims->is_integer($max_length) || !(0 <= $max_length)) {
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
unless ($context->prims->is_integer($max_length) and 0 <= $max_length) 2 19 21
Condition100%3/3
$context->prims->is_integer($max_length) and 0 <= $max_length
!ll&&!rl&&r
1119
MC/DC100%2/2
$context->prims->is_integer($max_length) and 0 <= $max_length
$context->prims->is_integer($max_length) 0 <= $max_length
Truth table100%3/3
A and B
A= $context->prims->is_integer($max_length)B= 0 <= $max_length
ABresult
0X0
100
111
19 2 croak sprintf '`maxLength` must be an integer. This integer must be greater than, or equal to, 0 at %s',
20 $context->position;
21 }
22 19 length $data <= $max_length;
23 21 });
24 }
25  
26 3 1;
« blib/lib/Valiemon/Attributes/MinItems.pm ↑ Summary blib/lib/Valiemon/Attributes/MinLength.pm »