line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::MaxItems; |
2
|
3
|
|
|
3
|
|
1408
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
78
|
|
3
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
60
|
|
4
|
3
|
|
|
3
|
|
9
|
use utf8; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
12
|
|
5
|
3
|
|
|
3
|
|
406
|
use parent qw(Valiemon::Attributes); |
|
3
|
|
|
|
|
231
|
|
|
3
|
|
|
|
|
12
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
140
|
use Carp qw(croak); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
477
|
|
8
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
0
|
30
|
sub attr_name { 'maxItems' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub is_valid { |
12
|
19
|
|
|
19
|
0
|
26
|
my ($class, $context, $schema, $data) = @_; |
13
|
|
|
|
|
|
|
|
14
|
19
|
100
|
|
|
|
41
|
return 1 unless ref $data eq 'ARRAY'; # ignore |
15
|
|
|
|
|
|
|
|
16
|
17
|
|
|
|
|
19
|
my $max_items = $schema->{maxItems}; |
17
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
18
|
17
|
100
|
66
|
17
|
|
33
|
if (!$context->prims->is_integer($max_items) || !(0 <= $max_items)) { |
19
|
2
|
|
|
|
|
3
|
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
|
|
|
|
|
41
|
scalar @$data <= $max_items; |
23
|
17
|
|
|
|
|
67
|
}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |