line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::AnyOf; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
21981
|
use strict; |
|
47
|
|
|
|
|
67
|
|
|
47
|
|
|
|
|
1108
|
|
4
|
47
|
|
|
47
|
|
130
|
use warnings; |
|
47
|
|
|
|
|
47
|
|
|
47
|
|
|
|
|
936
|
|
5
|
47
|
|
|
47
|
|
138
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
50
|
|
|
47
|
|
|
|
|
168
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
1950
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
54
|
|
|
47
|
|
|
|
|
12645
|
|
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
|
25
|
my ($class, $context, $schema, $instance) = @_; |
15
|
|
|
|
|
|
|
|
16
|
22
|
|
|
|
|
56
|
my $any_of = $class->keyword_value($schema); |
17
|
22
|
|
|
|
|
21
|
my $valid_cnt = 0; |
18
|
|
|
|
|
|
|
|
19
|
22
|
100
|
|
|
|
38
|
if (scalar(@$any_of) == 1) { |
20
|
1
|
|
|
|
|
1
|
my $sub_schema = $any_of->[0]; |
21
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
22
|
1
|
|
|
|
|
4
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/0"; |
23
|
1
|
|
|
|
|
2
|
$context->validate($sub_schema, $instance); |
24
|
1
|
|
|
|
|
2
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
21
|
|
|
|
|
48
|
for (my $i = 0, my $l = scalar(@$any_of); $i < $l; $i++) { |
28
|
42
|
|
|
|
|
37
|
my $sub_schema = $any_of->[$i]; |
29
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
30
|
42
|
|
|
|
|
114
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . $i; |
31
|
42
|
|
|
|
|
50
|
local $context->{errors} = []; |
32
|
42
|
|
|
|
|
78
|
$context->validate($sub_schema, $instance); |
33
|
42
|
100
|
|
|
|
28
|
$valid_cnt += 1 unless scalar @{ $context->{errors} }; |
|
42
|
|
|
|
|
175
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
21
|
100
|
|
|
|
41
|
if ($valid_cnt == 0) { |
37
|
7
|
|
|
|
|
15
|
$context->log_error("The instance is not valid to any of schemas"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |