line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::OneOf; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
37296
|
use strict; |
|
47
|
|
|
|
|
92
|
|
|
47
|
|
|
|
|
1353
|
|
4
|
47
|
|
|
47
|
|
242
|
use warnings; |
|
47
|
|
|
|
|
87
|
|
|
47
|
|
|
|
|
1399
|
|
5
|
47
|
|
|
47
|
|
233
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
91
|
|
|
47
|
|
|
|
|
252
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
2477
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
92
|
|
|
47
|
|
|
|
|
19618
|
|
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
|
46
|
my ($class, $context, $schema, $instance) = @_; |
15
|
|
|
|
|
|
|
|
16
|
20
|
|
|
|
|
123
|
my $one_of = $class->keyword_value($schema); |
17
|
20
|
|
|
|
|
41
|
my $valid_cnt = 0; |
18
|
|
|
|
|
|
|
|
19
|
20
|
100
|
|
|
|
72
|
if (scalar(@$one_of) == 1) { |
20
|
1
|
|
|
|
|
3
|
my $sub_schema = $one_of->[0]; |
21
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
22
|
1
|
|
|
|
|
6
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/0"; |
23
|
1
|
|
|
|
|
4
|
$context->validate($sub_schema, $instance); |
24
|
1
|
|
|
|
|
4
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
19
|
|
|
|
|
68
|
for (my $i = 0, my $l = scalar(@$one_of); $i < $l; $i++) { |
28
|
38
|
|
|
|
|
73
|
my $sub_schema = $one_of->[$i]; |
29
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
30
|
38
|
|
|
|
|
203
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . $i; |
31
|
38
|
|
|
|
|
167
|
local $context->{errors} = []; |
32
|
38
|
|
|
|
|
145
|
$context->validate($sub_schema, $instance); |
33
|
38
|
100
|
|
|
|
59
|
$valid_cnt += 1 unless scalar @{ $context->{errors} }; |
|
38
|
|
|
|
|
294
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
19
|
100
|
|
|
|
71
|
unless ($valid_cnt == 1) { |
37
|
10
|
|
|
|
|
56
|
$context->log_error("The instance is not matched to one of schemas"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |