line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::Enum; |
2
|
|
|
|
|
|
|
|
3
|
44
|
|
|
44
|
|
29755
|
use strict; |
|
44
|
|
|
|
|
81
|
|
|
44
|
|
|
|
|
1043
|
|
4
|
44
|
|
|
44
|
|
192
|
use warnings; |
|
44
|
|
|
|
|
73
|
|
|
44
|
|
|
|
|
1114
|
|
5
|
44
|
|
|
44
|
|
183
|
use parent qw(JSV::Keyword); |
|
44
|
|
|
|
|
72
|
|
|
44
|
|
|
|
|
204
|
|
6
|
|
|
|
|
|
|
|
7
|
44
|
|
|
44
|
|
2010
|
use JSV::Keyword qw(:constants); |
|
44
|
|
|
|
|
72
|
|
|
44
|
|
|
|
|
18098
|
|
8
|
44
|
|
|
44
|
|
287
|
use JSON; |
|
44
|
|
|
|
|
76
|
|
|
44
|
|
|
|
|
249
|
|
9
|
44
|
|
|
44
|
|
40736
|
use List::MoreUtils qw(firstidx); |
|
44
|
|
|
|
|
526980
|
|
|
44
|
|
|
|
|
328
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub instance_type() { INSTANCE_TYPE_ANY(); } |
12
|
|
|
|
|
|
|
sub keyword() { "enum" } |
13
|
|
|
|
|
|
|
sub keyword_priority() { 10; } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub validate { |
16
|
78
|
|
|
78
|
0
|
161
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
78
|
|
|
|
|
273
|
my $enum = $class->keyword_value($schema); |
19
|
78
|
|
|
|
|
260
|
my $instance_as_json = $context->json->encode($instance); |
20
|
78
|
|
|
166
|
|
1024
|
my $matched_idx = firstidx { $instance_as_json eq $context->json->encode($_); } @$enum; |
|
166
|
|
|
|
|
857
|
|
21
|
|
|
|
|
|
|
|
22
|
78
|
100
|
|
|
|
788
|
if ($matched_idx == -1) { |
23
|
15
|
|
|
|
|
60
|
$context->log_error("The instance value does not be included in the enum list"); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |