line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::Enum; |
2
|
3
|
|
|
3
|
|
2009
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
94
|
|
3
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
79
|
|
4
|
3
|
|
|
3
|
|
15
|
use utf8; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
19
|
|
5
|
3
|
|
|
3
|
|
522
|
use parent qw(Valiemon::Attributes); |
|
3
|
|
|
|
|
299
|
|
|
3
|
|
|
|
|
17
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
184
|
use Carp qw(croak); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
149
|
|
8
|
3
|
|
|
3
|
|
546
|
use List::MoreUtils qw(any); |
|
3
|
|
|
|
|
12504
|
|
|
3
|
|
|
|
|
21
|
|
9
|
|
|
|
|
|
|
|
10
|
35
|
|
|
35
|
0
|
113
|
sub attr_name { 'enum' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub is_valid { |
13
|
35
|
|
|
35
|
0
|
98
|
my ($class, $context, $schema, $data) = @_; |
14
|
|
|
|
|
|
|
|
15
|
35
|
|
|
|
|
69
|
my $enum = $schema->{enum}; |
16
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
17
|
35
|
50
|
33
|
35
|
|
181
|
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
|
35
|
|
|
|
|
165
|
any { $context->prims->is_equal($data, $_) } @$enum; |
|
96
|
|
|
|
|
267
|
|
22
|
35
|
|
|
|
|
200
|
}); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |