line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::Enum; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
35759
|
use strict; |
|
47
|
|
|
|
|
100
|
|
|
47
|
|
|
|
|
1249
|
|
4
|
47
|
|
|
47
|
|
243
|
use warnings; |
|
47
|
|
|
|
|
94
|
|
|
47
|
|
|
|
|
1351
|
|
5
|
47
|
|
|
47
|
|
235
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
91
|
|
|
47
|
|
|
|
|
270
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
2700
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
116
|
|
|
47
|
|
|
|
|
5778
|
|
8
|
47
|
|
|
47
|
|
265
|
use JSON; |
|
47
|
|
|
|
|
95
|
|
|
47
|
|
|
|
|
401
|
|
9
|
47
|
|
|
47
|
|
48653
|
use List::MoreUtils qw(firstidx); |
|
47
|
|
|
|
|
610024
|
|
|
47
|
|
|
|
|
419
|
|
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
|
181
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
78
|
|
|
|
|
278
|
my $enum = $class->keyword_value($schema); |
19
|
78
|
|
|
|
|
284
|
my $instance_as_json = $context->json->encode($instance); |
20
|
78
|
|
|
166
|
|
1143
|
my $matched_idx = firstidx { $instance_as_json eq $context->json->encode($_); } @$enum; |
|
166
|
|
|
|
|
876
|
|
21
|
|
|
|
|
|
|
|
22
|
78
|
100
|
|
|
|
912
|
if ($matched_idx == -1) { |
23
|
15
|
|
|
|
|
59
|
$context->log_error("The instance value does not be included in the enum list"); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |