line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::OneOf; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
22309
|
use strict; |
|
47
|
|
|
|
|
51
|
|
|
47
|
|
|
|
|
1105
|
|
4
|
47
|
|
|
47
|
|
135
|
use warnings; |
|
47
|
|
|
|
|
46
|
|
|
47
|
|
|
|
|
949
|
|
5
|
47
|
|
|
47
|
|
120
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
53
|
|
|
47
|
|
|
|
|
153
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
1917
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
51
|
|
|
47
|
|
|
|
|
13164
|
|
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
|
25
|
my ($class, $context, $schema, $instance) = @_; |
15
|
|
|
|
|
|
|
|
16
|
20
|
|
|
|
|
58
|
my $one_of = $class->keyword_value($schema); |
17
|
20
|
|
|
|
|
17
|
my $valid_cnt = 0; |
18
|
|
|
|
|
|
|
|
19
|
20
|
100
|
|
|
|
40
|
if (scalar(@$one_of) == 1) { |
20
|
1
|
|
|
|
|
1
|
my $sub_schema = $one_of->[0]; |
21
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
22
|
1
|
|
|
|
|
5
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/0"; |
23
|
1
|
|
|
|
|
3
|
$context->validate($sub_schema, $instance); |
24
|
1
|
|
|
|
|
2
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
19
|
|
|
|
|
47
|
for (my $i = 0, my $l = scalar(@$one_of); $i < $l; $i++) { |
28
|
38
|
|
|
|
|
29
|
my $sub_schema = $one_of->[$i]; |
29
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
30
|
38
|
|
|
|
|
116
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . $i; |
31
|
38
|
|
|
|
|
43
|
local $context->{errors} = []; |
32
|
38
|
|
|
|
|
73
|
$context->validate($sub_schema, $instance); |
33
|
38
|
100
|
|
|
|
31
|
$valid_cnt += 1 unless scalar @{ $context->{errors} }; |
|
38
|
|
|
|
|
158
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
19
|
100
|
|
|
|
38
|
unless ($valid_cnt == 1) { |
37
|
10
|
|
|
|
|
31
|
$context->log_error("The instance is not matched to one of schemas"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |