blib/lib/Valiemon/Attributes/MinLength.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/MaxLength.pm ↑ Summary blib/lib/Valiemon/Attributes/Minimum.pm »
1 package Valiemon::Attributes::MinLength;
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 22 ▶sub attr_name { 'minLength' }
Subroutine attr_name: called CC=1 SCAR=0.0
Pod undocumented
10  
11 sub is_valid {
12 22 ▶ my ($class, $context, $schema, $data) = @_;
Subroutine is_valid: called CC=2 SCAR=6.9
Pod undocumented
13  
14 22 ▶ return 1 unless $context->prims->is_string($data); # ignore
Branch: 1 branch
BranchTrueFalseTotal
unless $context->prims->is_string($data) 0 22 22
15  
16 22 my $min_length = $schema->{minLength};
17 $context->in_attr($class, sub {
18 22 ▶ if (!$context->prims->is_integer($min_length) || !(0 <= $min_length)) {
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
unless ($context->prims->is_integer($min_length) and 0 <= $min_length) 2 20 22
Condition100%3/3
$context->prims->is_integer($min_length) and 0 <= $min_length
!ll&&!rl&&r
1120
MC/DC100%2/2
$context->prims->is_integer($min_length) and 0 <= $min_length
$context->prims->is_integer($min_length) 0 <= $min_length
Truth table100%3/3
A and B
A= $context->prims->is_integer($min_length)B= 0 <= $min_length
ABresult
0X0
100
111
19 2 croak sprintf '`minLength` must be an integer. This integer must be greater than, or equal to, 0 at %s',
20 $context->position;
21 }
22 20 $min_length <= length $data;
23 22 });
24 }
25  
26 3 1;
« blib/lib/Valiemon/Attributes/MaxLength.pm ↑ Summary blib/lib/Valiemon/Attributes/Minimum.pm »