line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::MaxItems; |
2
|
3
|
|
|
3
|
|
2001
|
use strict; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
96
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
79
|
|
4
|
3
|
|
|
3
|
|
16
|
use utf8; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
17
|
|
5
|
3
|
|
|
3
|
|
517
|
use parent qw(Valiemon::Attributes); |
|
3
|
|
|
|
|
311
|
|
|
3
|
|
|
|
|
17
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
198
|
use Carp qw(croak); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
625
|
|
8
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
0
|
55
|
sub attr_name { 'maxItems' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub is_valid { |
12
|
19
|
|
|
19
|
0
|
51
|
my ($class, $context, $schema, $data) = @_; |
13
|
|
|
|
|
|
|
|
14
|
19
|
100
|
|
|
|
57
|
return 1 unless ref $data eq 'ARRAY'; # ignore |
15
|
|
|
|
|
|
|
|
16
|
17
|
|
|
|
|
34
|
my $max_items = $schema->{maxItems}; |
17
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
18
|
17
|
100
|
66
|
17
|
|
49
|
if (!$context->prims->is_integer($max_items) || !(0 <= $max_items)) { |
19
|
2
|
|
|
|
|
7
|
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
|
|
|
|
|
59
|
scalar @$data <= $max_items; |
23
|
17
|
|
|
|
|
98
|
}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |