line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::OneOf; |
2
|
|
|
|
|
|
|
|
3
|
44
|
|
|
44
|
|
36347
|
use strict; |
|
44
|
|
|
|
|
78
|
|
|
44
|
|
|
|
|
1048
|
|
4
|
44
|
|
|
44
|
|
193
|
use warnings; |
|
44
|
|
|
|
|
74
|
|
|
44
|
|
|
|
|
1065
|
|
5
|
44
|
|
|
44
|
|
180
|
use parent qw(JSV::Keyword); |
|
44
|
|
|
|
|
77
|
|
|
44
|
|
|
|
|
195
|
|
6
|
|
|
|
|
|
|
|
7
|
44
|
|
|
44
|
|
1977
|
use JSV::Keyword qw(:constants); |
|
44
|
|
|
|
|
75
|
|
|
44
|
|
|
|
|
15301
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub instance_type() { INSTANCE_TYPE_ANY(); } |
10
|
|
|
|
|
|
|
sub keyword() { "oneOf" } |
11
|
|
|
|
|
|
|
sub keyword_priority() { 10; } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub validate { |
14
|
20
|
|
|
20
|
0
|
43
|
my ($class, $context, $schema, $instance) = @_; |
15
|
|
|
|
|
|
|
|
16
|
20
|
|
|
|
|
86
|
my $one_of = $class->keyword_value($schema); |
17
|
20
|
|
|
|
|
34
|
my $valid_cnt = 0; |
18
|
|
|
|
|
|
|
|
19
|
20
|
100
|
|
|
|
76
|
if (scalar(@$one_of) == 1) { |
20
|
1
|
|
|
|
|
3
|
my $sub_schema = $one_of->[0]; |
21
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
22
|
1
|
|
|
|
|
7
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/0"; |
23
|
1
|
|
|
|
|
4
|
$context->validate($sub_schema, $instance); |
24
|
1
|
|
|
|
|
2
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
19
|
|
|
|
|
60
|
for (my $i = 0, my $l = scalar(@$one_of); $i < $l; $i++) { |
28
|
38
|
|
|
|
|
59
|
my $sub_schema = $one_of->[$i]; |
29
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
30
|
38
|
|
|
|
|
168
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . $i; |
31
|
38
|
|
|
|
|
81
|
local $context->{errors} = []; |
32
|
38
|
|
|
|
|
117
|
$context->validate($sub_schema, $instance); |
33
|
38
|
100
|
|
|
|
52
|
$valid_cnt += 1 unless scalar @{ $context->{errors} }; |
|
38
|
|
|
|
|
236
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
19
|
100
|
|
|
|
59
|
unless ($valid_cnt == 1) { |
37
|
10
|
|
|
|
|
42
|
$context->log_error("The instance is not matched to one of schemas"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |