line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::AnyOf; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
36483
|
use strict; |
|
47
|
|
|
|
|
101
|
|
|
47
|
|
|
|
|
1307
|
|
4
|
47
|
|
|
47
|
|
239
|
use warnings; |
|
47
|
|
|
|
|
95
|
|
|
47
|
|
|
|
|
1298
|
|
5
|
47
|
|
|
47
|
|
237
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
101
|
|
|
47
|
|
|
|
|
296
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
2536
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
130
|
|
|
47
|
|
|
|
|
19033
|
|
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
|
65
|
my ($class, $context, $schema, $instance) = @_; |
15
|
|
|
|
|
|
|
|
16
|
22
|
|
|
|
|
106
|
my $any_of = $class->keyword_value($schema); |
17
|
22
|
|
|
|
|
48
|
my $valid_cnt = 0; |
18
|
|
|
|
|
|
|
|
19
|
22
|
100
|
|
|
|
90
|
if (scalar(@$any_of) == 1) { |
20
|
1
|
|
|
|
|
2
|
my $sub_schema = $any_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
|
|
|
|
|
3
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
21
|
|
|
|
|
95
|
for (my $i = 0, my $l = scalar(@$any_of); $i < $l; $i++) { |
28
|
42
|
|
|
|
|
77
|
my $sub_schema = $any_of->[$i]; |
29
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
30
|
42
|
|
|
|
|
240
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . $i; |
31
|
42
|
|
|
|
|
125
|
local $context->{errors} = []; |
32
|
42
|
|
|
|
|
185
|
$context->validate($sub_schema, $instance); |
33
|
42
|
100
|
|
|
|
65
|
$valid_cnt += 1 unless scalar @{ $context->{errors} }; |
|
42
|
|
|
|
|
369
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
21
|
100
|
|
|
|
84
|
if ($valid_cnt == 0) { |
37
|
7
|
|
|
|
|
28
|
$context->log_error("The instance is not valid to any of schemas"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |