line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSV::Keyword::Draft4::Dependencies; |
2
|
|
|
|
|
|
|
|
3
|
44
|
|
|
44
|
|
36108
|
use strict; |
|
44
|
|
|
|
|
81
|
|
|
44
|
|
|
|
|
1421
|
|
4
|
44
|
|
|
44
|
|
191
|
use warnings; |
|
44
|
|
|
|
|
292
|
|
|
44
|
|
|
|
|
1297
|
|
5
|
44
|
|
|
44
|
|
182
|
use parent qw(JSV::Keyword); |
|
44
|
|
|
|
|
65
|
|
|
44
|
|
|
|
|
196
|
|
6
|
|
|
|
|
|
|
|
7
|
44
|
|
|
44
|
|
3271
|
use JSV::Keyword qw(:constants); |
|
44
|
|
|
|
|
76
|
|
|
44
|
|
|
|
|
6652
|
|
8
|
44
|
|
|
44
|
|
208
|
use JSV::Util::Type qw(escape_json_pointer); |
|
44
|
|
|
|
|
77
|
|
|
44
|
|
|
|
|
3164
|
|
9
|
44
|
|
|
44
|
|
418
|
use List::Util qw(first); |
|
44
|
|
|
|
|
73
|
|
|
44
|
|
|
|
|
19302
|
|
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
|
95
|
my ($class, $context, $schema, $instance) = @_; |
17
|
|
|
|
|
|
|
|
18
|
54
|
|
|
|
|
151
|
my $dependencies = $class->keyword_value($schema); |
19
|
54
|
|
50
|
|
|
130
|
$dependencies ||= {}; |
20
|
|
|
|
|
|
|
|
21
|
54
|
|
|
|
|
126
|
for my $property (keys %$dependencies) { |
22
|
62
|
100
|
|
|
|
177
|
next unless (exists $instance->{$property}); |
23
|
|
|
|
|
|
|
|
24
|
34
|
|
|
|
|
106
|
local $context->{current_pointer} = $context->{current_pointer} . "/" . escape_json_pointer( $property ); |
25
|
|
|
|
|
|
|
local $context->{current_schema_pointer} = |
26
|
34
|
|
|
|
|
140
|
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . escape_json_pointer( $property ); |
27
|
|
|
|
|
|
|
|
28
|
34
|
100
|
|
|
|
121
|
if (ref $dependencies->{$property} eq "ARRAY") { |
|
|
50
|
|
|
|
|
|
29
|
21
|
|
|
25
|
|
71
|
my $found_against_dependency = first { !exists $instance->{$_} } @{$dependencies->{$property}}; |
|
25
|
|
|
|
|
53
|
|
|
21
|
|
|
|
|
91
|
|
30
|
21
|
100
|
|
|
|
94
|
if ($found_against_dependency) { |
31
|
15
|
|
|
|
|
88
|
$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
|
|
|
|
|
46
|
$context->validate($dependencies->{$property}, $instance); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |