line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::Dependencies; |
2
|
|
|
|
|
|
|
|
3
|
47
|
|
|
47
|
|
37365
|
use strict; |
|
47
|
|
|
|
|
102
|
|
|
47
|
|
|
|
|
1298
|
|
4
|
47
|
|
|
47
|
|
249
|
use warnings; |
|
47
|
|
|
|
|
98
|
|
|
47
|
|
|
|
|
1434
|
|
5
|
47
|
|
|
47
|
|
238
|
use parent qw(JSV::Keyword); |
|
47
|
|
|
|
|
92
|
|
|
47
|
|
|
|
|
243
|
|
6
|
|
|
|
|
|
|
|
7
|
47
|
|
|
47
|
|
2684
|
use JSV::Keyword qw(:constants); |
|
47
|
|
|
|
|
90
|
|
|
47
|
|
|
|
|
6016
|
|
8
|
47
|
|
|
47
|
|
263
|
use JSV::Util::Type qw(escape_json_pointer); |
|
47
|
|
|
|
|
98
|
|
|
47
|
|
|
|
|
2648
|
|
9
|
47
|
|
|
47
|
|
256
|
use List::Util qw(first); |
|
47
|
|
|
|
|
85
|
|
|
47
|
|
|
|
|
20440
|
|
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
|
109
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
54
|
|
|
|
|
197
|
my $dependencies = $class->keyword_value($schema); |
19
|
54
|
|
50
|
|
|
167
|
$dependencies ||= {}; |
20
|
|
|
|
|
|
|
|
21
|
54
|
|
|
|
|
168
|
for my $property (keys %$dependencies) { |
22
|
62
|
100
|
|
|
|
232
|
next unless (exists $instance->{$property}); |
23
|
|
|
|
|
|
|
|
24
|
34
|
|
|
|
|
151
|
local $context->{current_pointer} = $context->{current_pointer} . "/" . escape_json_pointer( $property ); |
25
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
26
|
34
|
|
|
|
|
178
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . escape_json_pointer( $property ); |
27
|
|
|
|
|
|
|
|
28
|
34
|
100
|
|
|
|
142
|
if (ref $dependencies->{$property} eq "ARRAY") { |
|
|
50
|
|
|
|
|
|
29
|
21
|
|
|
25
|
|
97
|
my $found_against_dependency = first { !exists $instance->{$_} } @{$dependencies->{$property}}; |
|
25
|
|
|
|
|
77
|
|
|
21
|
|
|
|
|
122
|
|
30
|
21
|
100
|
|
|
|
133
|
if ($found_against_dependency) { |
31
|
15
|
|
|
|
|
120
|
$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
|
|
|
|
|
55
|
$context->validate($dependencies->{$property}, $instance); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |