line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::Enum; |
2
|
3
|
|
|
3
|
|
1412
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
78
|
|
3
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
65
|
|
4
|
3
|
|
|
3
|
|
10
|
use utf8; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
13
|
|
5
|
3
|
|
|
3
|
|
416
|
use parent qw(Valiemon::Attributes); |
|
3
|
|
|
|
|
270
|
|
|
3
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
151
|
use Carp qw(croak); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
132
|
|
8
|
3
|
|
|
3
|
|
427
|
use List::MoreUtils qw(any); |
|
3
|
|
|
|
|
7681
|
|
|
3
|
|
|
|
|
19
|
|
9
|
|
|
|
|
|
|
|
10
|
34
|
|
|
34
|
0
|
66
|
sub attr_name { 'enum' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub is_valid { |
13
|
34
|
|
|
34
|
0
|
42
|
my ($class, $context, $schema, $data) = @_; |
14
|
|
|
|
|
|
|
|
15
|
34
|
|
|
|
|
39
|
my $enum = $schema->{enum}; |
16
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
17
|
34
|
50
|
33
|
34
|
|
147
|
if (ref $enum ne 'ARRAY' || scalar @$enum < 1) { |
18
|
0
|
|
|
|
|
0
|
croak sprintf '`enum` must be an array and have at leas one element at %s', $context->position |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
34
|
|
|
|
|
120
|
any { $context->prims->is_equal($data, $_) } @$enum; |
|
95
|
|
|
|
|
183
|
|
22
|
34
|
|
|
|
|
144
|
}); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |