« blib/lib/Valiemon/Attributes/AdditionalProperties.pm
↑ Summary
blib/lib/Valiemon/Attributes/MinItems.pm »
| 1 | package Valiemon::Attributes::MaxItems; | ||||||||||||||||||||||||||||
| 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 | 17 | ▶ | sub attr_name { 'maxItems' } | ||||||||||||||||||||||||||
|
Subroutine
attr_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub is_valid { | ||||||||||||||||||||||||||||
| 12 | 19 | ▶ | my ($class, $context, $schema, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 19 | ▶ | return 1 unless ref $data eq 'ARRAY'; # ignore | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 17 | my $max_items = $schema->{maxItems}; | |||||||||||||||||||||||||||
| 17 | $context->in_attr($class, sub { | ||||||||||||||||||||||||||||
| 18 | 17 | ▶ | if (!$context->prims->is_integer($max_items) || !(0 <= $max_items)) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition66%2/3
$context->prims->is_integer($max_items) and 0 <= $max_items
MC/DC50%1/2
$context->prims->is_integer($max_items) and 0 <= $max_items
$context->prims->is_integer($max_items)
0 <= $max_items
Truth table66%2/3
A and B
A= $context->prims->is_integer($max_items)B= 0 <= $max_items
| |||||||||||||||||||||||||||||
| 19 | 2 | croak sprintf '`maxItems` must be an integer. This integer must be greater than, or equal to 0 at %s', | |||||||||||||||||||||||||||
| 20 | $context->position; | ||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | 15 | scalar @$data <= $max_items; | |||||||||||||||||||||||||||
| 23 | 17 | }); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 3 | 1; | |||||||||||||||||||||||||||