| 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
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
$context->prims->is_integer($min_length) and 0 <= $min_length
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
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||