line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::Enum; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
21447
|
use strict; |
|
47
|
|
|
|
|
59
|
|
|
47
|
|
|
|
|
1079
|
|
4
|
47
|
|
|
47
|
|
144
|
use warnings; |
|
47
|
|
|
|
|
51
|
|
|
47
|
|
|
|
|
989
|
|
5
|
47
|
|
|
47
|
|
135
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
59
|
|
|
47
|
|
|
|
|
177
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
2096
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
61
|
|
|
47
|
|
|
|
|
4121
|
|
8
|
47
|
|
|
47
|
|
222
|
use JSON; |
|
47
|
|
|
|
|
52
|
|
|
47
|
|
|
|
|
209
|
|
9
|
47
|
|
|
47
|
|
25965
|
use List::MoreUtils qw(firstidx); |
|
47
|
|
|
|
|
372908
|
|
|
47
|
|
|
|
|
245
|
|
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
|
84
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
78
|
|
|
|
|
153
|
my $enum = $class->keyword_value($schema); |
19
|
78
|
|
|
|
|
128
|
my $instance_as_json = $context->json->encode($instance); |
20
|
78
|
|
|
166
|
|
708
|
my $matched_idx = firstidx { $instance_as_json eq $context->json->encode($_); } @$enum; |
|
166
|
|
|
|
|
426
|
|
21
|
|
|
|
|
|
|
|
22
|
78
|
100
|
|
|
|
464
|
if ($matched_idx == -1) { |
23
|
15
|
|
|
|
|
33
|
$context->log_error("The instance value does not be included in the enum list"); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |