line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::Dependencies; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
22856
|
use strict; |
|
47
|
|
|
|
|
58
|
|
|
47
|
|
|
|
|
1099
|
|
4
|
47
|
|
|
47
|
|
135
|
use warnings; |
|
47
|
|
|
|
|
41
|
|
|
47
|
|
|
|
|
942
|
|
5
|
47
|
|
|
47
|
|
124
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
43
|
|
|
47
|
|
|
|
|
149
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
1962
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
56
|
|
|
47
|
|
|
|
|
4227
|
|
8
|
47
|
|
|
47
|
|
182
|
use JSV::Util::Type qw(escape_json_pointer); |
|
47
|
|
|
|
|
56
|
|
|
47
|
|
|
|
|
1957
|
|
9
|
47
|
|
|
47
|
|
157
|
use List::Util qw(first); |
|
47
|
|
|
|
|
47
|
|
|
47
|
|
|
|
|
12583
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub instance_type() { INSTANCE_TYPE_OBJECT(); } |
12
|
|
|
|
|
|
|
sub keyword() { "dependencies" } |
13
|
|
|
|
|
|
|
sub keyword_priority() { 10; } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub validate { |
16
|
54
|
|
|
54
|
0
|
57
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
54
|
|
|
|
|
93
|
my $dependencies = $class->keyword_value($schema); |
19
|
54
|
|
50
|
|
|
86
|
$dependencies ||= {}; |
20
|
|
|
|
|
|
|
|
21
|
54
|
|
|
|
|
94
|
for my $property (keys %$dependencies) { |
22
|
62
|
100
|
|
|
|
122
|
next unless (exists $instance->{$property}); |
23
|
|
|
|
|
|
|
|
24
|
34
|
|
|
|
|
96
|
local $context->{current_pointer} = $context->{current_pointer} . "/" . escape_json_pointer( $property ); |
25
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
26
|
34
|
|
|
|
|
92
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . escape_json_pointer( $property ); |
27
|
|
|
|
|
|
|
|
28
|
34
|
100
|
|
|
|
80
|
if (ref $dependencies->{$property} eq "ARRAY") { |
|
|
50
|
|
|
|
|
|
29
|
21
|
|
|
25
|
|
56
|
my $found_against_dependency = first { !exists $instance->{$_} } @{$dependencies->{$property}}; |
|
25
|
|
|
|
|
35
|
|
|
21
|
|
|
|
|
69
|
|
30
|
21
|
100
|
|
|
|
72
|
if ($found_against_dependency) { |
31
|
15
|
|
|
|
|
65
|
$context->log_error(sprintf("%s property has dependency on the %s field", $property, $found_against_dependency)); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif (ref $dependencies->{$property} eq "HASH") { |
35
|
13
|
|
|
|
|
33
|
$context->validate($dependencies->{$property}, $instance); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |