line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::AnyOf; |
2
|
|
|
|
|
|
|
|
3
|
44
|
|
|
44
|
|
29613
|
use strict; |
|
44
|
|
|
|
|
79
|
|
|
44
|
|
|
|
|
1041
|
|
4
|
44
|
|
|
44
|
|
190
|
use warnings; |
|
44
|
|
|
|
|
72
|
|
|
44
|
|
|
|
|
1079
|
|
5
|
44
|
|
|
44
|
|
193
|
use parent qw(JSV::Keyword); |
|
44
|
|
|
|
|
75
|
|
|
44
|
|
|
|
|
202
|
|
6
|
|
|
|
|
|
|
|
7
|
44
|
|
|
44
|
|
2071
|
use JSV::Keyword qw(:constants); |
|
44
|
|
|
|
|
78
|
|
|
44
|
|
|
|
|
15269
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub instance_type() { INSTANCE_TYPE_ANY(); } |
10
|
|
|
|
|
|
|
sub keyword() { "anyOf" } |
11
|
|
|
|
|
|
|
sub keyword_priority() { 10; } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub validate { |
14
|
22
|
|
|
22
|
0
|
45
|
my ($class, $context, $schema, $instance) = @_; |
15
|
|
|
|
|
|
|
|
16
|
22
|
|
|
|
|
100
|
my $any_of = $class->keyword_value($schema); |
17
|
22
|
|
|
|
|
39
|
my $valid_cnt = 0; |
18
|
|
|
|
|
|
|
|
19
|
22
|
100
|
|
|
|
78
|
if (scalar(@$any_of) == 1) { |
20
|
1
|
|
|
|
|
3
|
my $sub_schema = $any_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
|
|
|
|
|
3
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
21
|
|
|
|
|
68
|
for (my $i = 0, my $l = scalar(@$any_of); $i < $l; $i++) { |
28
|
42
|
|
|
|
|
72
|
my $sub_schema = $any_of->[$i]; |
29
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
30
|
42
|
|
|
|
|
196
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . $i; |
31
|
42
|
|
|
|
|
98
|
local $context->{errors} = []; |
32
|
42
|
|
|
|
|
127
|
$context->validate($sub_schema, $instance); |
33
|
42
|
100
|
|
|
|
55
|
$valid_cnt += 1 unless scalar @{ $context->{errors} }; |
|
42
|
|
|
|
|
286
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
21
|
100
|
|
|
|
71
|
if ($valid_cnt == 0) { |
37
|
7
|
|
|
|
|
27
|
$context->log_error("The instance is not valid to any of schemas"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |