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