line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::MaxItems; |
2
|
1
|
|
|
1
|
|
813
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
4
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
738
|
use parent qw(Valiemon::Attributes); |
|
1
|
|
|
|
|
366
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
78
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
254
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
0
|
13
|
sub attr_name { 'maxItems' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub is_valid { |
12
|
5
|
|
|
5
|
0
|
9
|
my ($class, $context, $schema, $data) = @_; |
13
|
|
|
|
|
|
|
|
14
|
5
|
50
|
|
|
|
14
|
return 1 unless ref $data eq 'ARRAY'; # ignore |
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
|
|
7
|
my $max_items = $schema->{maxItems}; |
17
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
18
|
5
|
100
|
66
|
5
|
|
14
|
if (!$context->prims->is_integer($max_items) || !(0 <= $max_items)) { |
19
|
2
|
|
|
|
|
6
|
croak sprintf '`maxItems` must be an integer. This integer must be greater than, or equal to 0 at %s', |
20
|
|
|
|
|
|
|
$context->position; |
21
|
|
|
|
|
|
|
} |
22
|
3
|
|
|
|
|
13
|
scalar @$data <= $max_items; |
23
|
5
|
|
|
|
|
31
|
}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |