| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
38
|
|
|
38
|
|
633414
|
use strict; |
|
|
38
|
|
|
|
|
80
|
|
|
|
38
|
|
|
|
|
1353
|
|
|
2
|
38
|
|
|
38
|
|
152
|
use warnings; |
|
|
38
|
|
|
|
|
69
|
|
|
|
38
|
|
|
|
|
2940
|
|
|
3
|
|
|
|
|
|
|
package JSON::Schema::Modern::Vocabulary::Applicator; |
|
4
|
|
|
|
|
|
|
# vim: set ts=8 sts=2 sw=2 tw=100 et : |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Implementation of the JSON Schema Applicator vocabulary |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.638'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
38
|
|
|
38
|
|
560
|
use 5.020; |
|
|
38
|
|
|
|
|
124
|
|
|
10
|
38
|
|
|
38
|
|
174
|
use Moo; |
|
|
38
|
|
|
|
|
65
|
|
|
|
38
|
|
|
|
|
213
|
|
|
11
|
38
|
|
|
38
|
|
12347
|
use strictures 2; |
|
|
38
|
|
|
|
|
334
|
|
|
|
38
|
|
|
|
|
1382
|
|
|
12
|
38
|
|
|
38
|
|
13515
|
use stable 0.031 'postderef'; |
|
|
38
|
|
|
|
|
541
|
|
|
|
38
|
|
|
|
|
232
|
|
|
13
|
38
|
|
|
38
|
|
6366
|
use experimental 0.026 qw(signatures args_array_with_signatures); |
|
|
38
|
|
|
|
|
635
|
|
|
|
38
|
|
|
|
|
177
|
|
|
14
|
38
|
|
|
38
|
|
2903
|
no autovivification warn => qw(fetch store exists delete); |
|
|
38
|
|
|
|
|
103
|
|
|
|
38
|
|
|
|
|
256
|
|
|
15
|
38
|
|
|
38
|
|
2709
|
use if "$]" >= 5.022, experimental => 're_strict'; |
|
|
38
|
|
|
|
|
89
|
|
|
|
38
|
|
|
|
|
794
|
|
|
16
|
38
|
|
|
38
|
|
2706
|
no if "$]" >= 5.031009, feature => 'indirect'; |
|
|
38
|
|
|
|
|
82
|
|
|
|
38
|
|
|
|
|
2267
|
|
|
17
|
38
|
|
|
38
|
|
218
|
no if "$]" >= 5.033001, feature => 'multidimensional'; |
|
|
38
|
|
|
|
|
70
|
|
|
|
38
|
|
|
|
|
1800
|
|
|
18
|
38
|
|
|
38
|
|
172
|
no if "$]" >= 5.033006, feature => 'bareword_filehandles'; |
|
|
38
|
|
|
|
|
81
|
|
|
|
38
|
|
|
|
|
1913
|
|
|
19
|
38
|
|
|
38
|
|
176
|
no if "$]" >= 5.041009, feature => 'smartmatch'; |
|
|
38
|
|
|
|
|
73
|
|
|
|
38
|
|
|
|
|
1355
|
|
|
20
|
38
|
|
|
38
|
|
148
|
no feature 'switch'; |
|
|
38
|
|
|
|
|
102
|
|
|
|
38
|
|
|
|
|
1324
|
|
|
21
|
38
|
|
|
38
|
|
220
|
use List::Util 1.45 'uniqstr'; |
|
|
38
|
|
|
|
|
902
|
|
|
|
38
|
|
|
|
|
3403
|
|
|
22
|
38
|
|
|
38
|
|
220
|
use if "$]" < 5.041010, 'List::Util' => 'any'; |
|
|
38
|
|
|
|
|
100
|
|
|
|
38
|
|
|
|
|
1514
|
|
|
23
|
38
|
|
|
38
|
|
182
|
use if "$]" >= 5.041010, experimental => 'keyword_any'; |
|
|
38
|
|
|
|
|
77
|
|
|
|
38
|
|
|
|
|
482
|
|
|
24
|
38
|
|
|
38
|
|
2802
|
use JSON::Schema::Modern::Utilities qw(is_type jsonp E A assert_keyword_type assert_pattern true is_elements_unique); |
|
|
38
|
|
|
|
|
87
|
|
|
|
38
|
|
|
|
|
2903
|
|
|
25
|
38
|
|
|
38
|
|
18408
|
use JSON::Schema::Modern::Vocabulary::Unevaluated; |
|
|
38
|
|
|
|
|
241
|
|
|
|
38
|
|
|
|
|
1512
|
|
|
26
|
38
|
|
|
38
|
|
262
|
use namespace::clean; |
|
|
38
|
|
|
|
|
95
|
|
|
|
38
|
|
|
|
|
162
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
with 'JSON::Schema::Modern::Vocabulary'; |
|
29
|
|
|
|
|
|
|
|
|
30
|
22
|
|
|
22
|
0
|
40
|
sub vocabulary ($class) { |
|
|
22
|
|
|
|
|
38
|
|
|
|
22
|
|
|
|
|
40
|
|
|
31
|
22
|
|
|
|
|
89
|
'https://json-schema.org/draft/2019-09/vocab/applicator' => 'draft2019-09', |
|
32
|
|
|
|
|
|
|
'https://json-schema.org/draft/2020-12/vocab/applicator' => 'draft2020-12'; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
18
|
|
|
18
|
0
|
32
|
sub evaluation_order ($class) { 3 } |
|
|
18
|
|
|
|
|
28
|
|
|
|
18
|
|
|
|
|
27
|
|
|
|
18
|
|
|
|
|
71
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# the keyword order is arbitrary, except: |
|
38
|
|
|
|
|
|
|
# - if must be evaluated before then, else |
|
39
|
|
|
|
|
|
|
# - items must be evaluated before additionalItems |
|
40
|
|
|
|
|
|
|
# - in-place applicators (allOf, anyOf, oneOf, not, if/then/else, dependentSchemas) and items, |
|
41
|
|
|
|
|
|
|
# additionalItems must be evaluated before unevaluatedItems (in the Unevaluated vocabulary) |
|
42
|
|
|
|
|
|
|
# - properties and patternProperties must be evaluated before additionalProperties |
|
43
|
|
|
|
|
|
|
# - in-place applicators and properties, patternProperties, additionalProperties must be evaluated |
|
44
|
|
|
|
|
|
|
# before unevaluatedProperties (in the Unevaluated vocabulary) |
|
45
|
|
|
|
|
|
|
# - contains must be evaluated before maxContains, minContains (implemented here, rather than in the Validation vocabulary) |
|
46
|
171
|
|
|
171
|
0
|
3457
|
sub keywords ($class, $spec_version) { |
|
|
171
|
|
|
|
|
293
|
|
|
|
171
|
|
|
|
|
278
|
|
|
|
171
|
|
|
|
|
299
|
|
|
47
|
|
|
|
|
|
|
return ( |
|
48
|
171
|
100
|
|
|
|
9922
|
qw(allOf anyOf oneOf not), |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$spec_version !~ /^draft[46]\z/ ? qw(if then else) : (), |
|
50
|
|
|
|
|
|
|
$spec_version =~ /^draft[467]\z/ ? 'dependencies' : (), |
|
51
|
|
|
|
|
|
|
$spec_version !~ /^draft[467]\z/ ? 'dependentSchemas' : (), |
|
52
|
|
|
|
|
|
|
$spec_version !~ /^draft(?:[467]|2019-09)\z/ ? 'prefixItems' : (), |
|
53
|
|
|
|
|
|
|
'items', |
|
54
|
|
|
|
|
|
|
$spec_version =~ /^draft(?:[467]|2019-09)\z/ ? 'additionalItems' : (), |
|
55
|
|
|
|
|
|
|
$spec_version ne 'draft4' ? 'contains' : (), |
|
56
|
|
|
|
|
|
|
qw(properties patternProperties additionalProperties), |
|
57
|
|
|
|
|
|
|
$spec_version ne 'draft4' ? 'propertyNames' : (), |
|
58
|
|
|
|
|
|
|
$spec_version eq 'draft2019-09' ? qw(unevaluatedItems unevaluatedProperties) : (), |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# in draft2019-09, the unevaluated keywords were part of the Applicator vocabulary |
|
63
|
|
|
|
|
|
|
foreach my $phase (qw(traverse eval)) { |
|
64
|
|
|
|
|
|
|
foreach my $type (qw(Items Properties)) { |
|
65
|
|
|
|
|
|
|
my $method = '_'.$phase.'_keyword_unevaluated'.$type; |
|
66
|
38
|
|
|
38
|
|
23168
|
no strict 'refs'; |
|
|
38
|
|
|
|
|
85
|
|
|
|
38
|
|
|
|
|
227760
|
|
|
67
|
|
|
|
|
|
|
*{__PACKAGE__.'::'.$method} = sub { |
|
68
|
1445
|
|
|
1445
|
|
13337
|
shift; |
|
69
|
1445
|
|
|
|
|
8252
|
JSON::Schema::Modern::Vocabulary::Unevaluated->$method(@_); |
|
70
|
|
|
|
|
|
|
}; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
1022
|
|
|
1022
|
|
5843
|
sub _traverse_keyword_allOf { shift->traverse_array_schemas(@_) } |
|
75
|
|
|
|
|
|
|
|
|
76
|
1083
|
|
|
1083
|
|
4479
|
sub _eval_keyword_allOf ($class, $data, $schema, $state) { |
|
|
1083
|
|
|
|
|
2419
|
|
|
|
1083
|
|
|
|
|
2185
|
|
|
|
1083
|
|
|
|
|
2139
|
|
|
|
1083
|
|
|
|
|
1965
|
|
|
|
1083
|
|
|
|
|
2026
|
|
|
77
|
1083
|
|
|
|
|
1989
|
my @invalid; |
|
78
|
1083
|
|
|
|
|
4974
|
foreach my $idx (0 .. $schema->{allOf}->$#*) { |
|
79
|
2549
|
100
|
|
|
|
41986
|
if ($class->eval($data, $schema->{allOf}[$idx], +{ %$state, |
|
80
|
|
|
|
|
|
|
keyword_path => $state->{keyword_path}.'/allOf/'.$idx })) { |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else { |
|
83
|
514
|
|
|
|
|
1493
|
push @invalid, $idx; |
|
84
|
514
|
100
|
|
|
|
4033
|
last if $state->{short_circuit}; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
1079
|
100
|
|
|
|
6815
|
return 1 if @invalid == 0; |
|
89
|
|
|
|
|
|
|
|
|
90
|
456
|
|
|
|
|
1274
|
my $pl = @invalid > 1; |
|
91
|
456
|
100
|
|
|
|
3404
|
return E($state, 'subschema%s %s %s not valid', $pl?'s':'', join(', ', @invalid), $pl?'are':'is'); |
|
|
|
100
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
719
|
|
|
719
|
|
3683
|
sub _traverse_keyword_anyOf { shift->traverse_array_schemas(@_) } |
|
95
|
|
|
|
|
|
|
|
|
96
|
766
|
|
|
766
|
|
1740
|
sub _eval_keyword_anyOf ($class, $data, $schema, $state) { |
|
|
766
|
|
|
|
|
2126
|
|
|
|
766
|
|
|
|
|
1619
|
|
|
|
766
|
|
|
|
|
1531
|
|
|
|
766
|
|
|
|
|
1511
|
|
|
|
766
|
|
|
|
|
1491
|
|
|
97
|
766
|
|
|
|
|
1281
|
my $valid = 0; |
|
98
|
766
|
|
|
|
|
1330
|
my @errors; |
|
99
|
766
|
|
|
|
|
3825
|
foreach my $idx (0 .. $schema->{anyOf}->$#*) { |
|
100
|
|
|
|
|
|
|
next if not $class->eval($data, $schema->{anyOf}[$idx], |
|
101
|
1369
|
100
|
|
|
|
23866
|
+{ %$state, errors => \@errors, keyword_path => $state->{keyword_path}.'/anyOf/'.$idx }); |
|
102
|
570
|
|
|
|
|
4387
|
++$valid; |
|
103
|
570
|
100
|
100
|
|
|
3492
|
last if $state->{short_circuit} and not $state->{collect_annotations}; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
765
|
100
|
|
|
|
3984
|
return 1 if $valid; |
|
107
|
272
|
|
|
|
|
1077
|
push $state->{errors}->@*, @errors; |
|
108
|
272
|
|
|
|
|
836
|
return E($state, 'no subschemas are valid'); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
701
|
|
|
701
|
|
3627
|
sub _traverse_keyword_oneOf { shift->traverse_array_schemas(@_) } |
|
112
|
|
|
|
|
|
|
|
|
113
|
661
|
|
|
661
|
|
5095
|
sub _eval_keyword_oneOf ($class, $data, $schema, $state) { |
|
|
661
|
|
|
|
|
1307
|
|
|
|
661
|
|
|
|
|
1176
|
|
|
|
661
|
|
|
|
|
968
|
|
|
|
661
|
|
|
|
|
1037
|
|
|
|
661
|
|
|
|
|
855
|
|
|
114
|
661
|
|
|
|
|
1132
|
my (@valid, @errors); |
|
115
|
661
|
|
|
|
|
2672
|
foreach my $idx (0 .. $schema->{oneOf}->$#*) { |
|
116
|
|
|
|
|
|
|
next if not $class->eval($data, $schema->{oneOf}[$idx], |
|
117
|
1412
|
100
|
|
|
|
23594
|
+{ %$state, errors => \@errors, keyword_path => $state->{keyword_path}.'/oneOf/'.$idx }); |
|
118
|
611
|
|
|
|
|
4735
|
push @valid, $idx; |
|
119
|
611
|
100
|
100
|
|
|
3257
|
last if @valid > 1 and $state->{short_circuit}; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
661
|
100
|
|
|
|
3411
|
return 1 if @valid == 1; |
|
123
|
|
|
|
|
|
|
|
|
124
|
336
|
100
|
|
|
|
878
|
if (not @valid) { |
|
125
|
196
|
|
|
|
|
651
|
push $state->{errors}->@*, @errors; |
|
126
|
196
|
|
|
|
|
608
|
return E($state, 'no subschemas are valid'); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
else { |
|
129
|
140
|
|
|
|
|
852
|
return E($state, 'multiple subschemas are valid: '.join(', ', @valid)); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
490
|
|
|
490
|
|
2626
|
sub _traverse_keyword_not { shift->traverse_subschema(@_) } |
|
134
|
|
|
|
|
|
|
|
|
135
|
468
|
|
|
468
|
|
8669
|
sub _eval_keyword_not ($class, $data, $schema, $state) { |
|
|
468
|
|
|
|
|
934
|
|
|
|
468
|
|
|
|
|
898
|
|
|
|
468
|
|
|
|
|
880
|
|
|
|
468
|
|
|
|
|
768
|
|
|
|
468
|
|
|
|
|
743
|
|
|
136
|
468
|
100
|
66
|
|
|
2036
|
return !$schema->{not} || E($state, 'subschema is true') if is_type('boolean', $schema->{not}); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
return 1 if not $class->eval($data, $schema->{not}, |
|
139
|
306
|
100
|
|
|
|
5790
|
+{ %$state, keyword_path => $state->{keyword_path}.'/not', |
|
140
|
|
|
|
|
|
|
short_circuit => 1, # errors do not propagate upward from this subschema |
|
141
|
|
|
|
|
|
|
collect_annotations => 0, # nor do annotations |
|
142
|
|
|
|
|
|
|
errors => [] }); |
|
143
|
|
|
|
|
|
|
|
|
144
|
230
|
|
|
|
|
1725
|
return E($state, 'subschema is valid'); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
410
|
|
|
410
|
|
2263
|
sub _traverse_keyword_if { shift->traverse_subschema(@_) } |
|
148
|
319
|
|
|
319
|
|
1362
|
sub _traverse_keyword_then { shift->traverse_subschema(@_) } |
|
149
|
268
|
|
|
268
|
|
1105
|
sub _traverse_keyword_else { shift->traverse_subschema(@_) } |
|
150
|
|
|
|
|
|
|
|
|
151
|
368
|
|
|
368
|
|
742
|
sub _eval_keyword_if ($class, $data, $schema, $state) { |
|
|
368
|
|
|
|
|
759
|
|
|
|
368
|
|
|
|
|
681
|
|
|
|
368
|
|
|
|
|
645
|
|
|
|
368
|
|
|
|
|
547
|
|
|
|
368
|
|
|
|
|
547
|
|
|
152
|
|
|
|
|
|
|
return 1 if not exists $schema->{then} and not exists $schema->{else} |
|
153
|
368
|
100
|
100
|
|
|
1831
|
and not $state->{collect_annotations}; |
|
|
|
|
100
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $keyword = $class->eval($data, $schema->{if}, |
|
155
|
335
|
100
|
|
|
|
6560
|
+{ %$state, keyword_path => $state->{keyword_path}.'/if', short_circuit => 1, errors => [] }) |
|
156
|
|
|
|
|
|
|
? 'then' : 'else'; |
|
157
|
|
|
|
|
|
|
|
|
158
|
334
|
100
|
|
|
|
3716
|
return 1 if not exists $schema->{$keyword}; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
return $schema->{$keyword} || E({ %$state, keyword => $keyword }, 'subschema is false') |
|
161
|
256
|
100
|
66
|
|
|
1003
|
if is_type('boolean', $schema->{$keyword}); |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
return 1 if $class->eval($data, $schema->{$keyword}, |
|
164
|
215
|
100
|
|
|
|
4688
|
+{ %$state, keyword_path => $state->{keyword_path}.'/'.$keyword }); |
|
165
|
90
|
|
|
|
|
1664
|
return E({ %$state, keyword => $keyword }, 'subschema is not valid'); |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
350
|
|
|
350
|
|
2077
|
sub _traverse_keyword_dependentSchemas { shift->traverse_object_schemas(@_) } |
|
169
|
|
|
|
|
|
|
|
|
170
|
328
|
|
|
328
|
|
688
|
sub _eval_keyword_dependentSchemas ($class, $data, $schema, $state) { |
|
|
328
|
|
|
|
|
702
|
|
|
|
328
|
|
|
|
|
654
|
|
|
|
328
|
|
|
|
|
710
|
|
|
|
328
|
|
|
|
|
563
|
|
|
|
328
|
|
|
|
|
538
|
|
|
171
|
328
|
100
|
|
|
|
1145
|
return 1 if not is_type('object', $data); |
|
172
|
|
|
|
|
|
|
|
|
173
|
222
|
|
|
|
|
484
|
my $valid = 1; |
|
174
|
222
|
|
|
|
|
1123
|
foreach my $property (sort keys $schema->{dependentSchemas}->%*) { |
|
175
|
272
|
100
|
|
|
|
975
|
next if not exists $data->{$property}; |
|
176
|
|
|
|
|
|
|
|
|
177
|
138
|
100
|
|
|
|
1191
|
if ($class->eval($data, $schema->{dependentSchemas}{$property}, |
|
178
|
|
|
|
|
|
|
+{ %$state, keyword_path => jsonp($state->{keyword_path}, 'dependentSchemas', $property) })) { |
|
179
|
34
|
|
|
|
|
294
|
next; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
104
|
|
|
|
|
654
|
$valid = 0; |
|
183
|
104
|
100
|
|
|
|
493
|
last if $state->{short_circuit}; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
222
|
100
|
|
|
|
815
|
return E($state, 'not all dependencies are satisfied') if not $valid; |
|
187
|
118
|
|
|
|
|
349
|
return 1; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
315
|
|
|
315
|
|
622
|
sub _traverse_keyword_dependencies ($class, $schema, $state) { |
|
|
315
|
|
|
|
|
631
|
|
|
|
315
|
|
|
|
|
615
|
|
|
|
315
|
|
|
|
|
560
|
|
|
|
315
|
|
|
|
|
458
|
|
|
191
|
315
|
50
|
|
|
|
1123
|
return if not assert_keyword_type($state, $schema, 'object'); |
|
192
|
|
|
|
|
|
|
|
|
193
|
315
|
|
|
|
|
534
|
my $valid = 1; |
|
194
|
315
|
|
|
|
|
1444
|
foreach my $property (sort keys $schema->{dependencies}->%*) { |
|
195
|
459
|
100
|
|
|
|
1309
|
if (is_type('array', $schema->{dependencies}{$property})) { |
|
196
|
|
|
|
|
|
|
# as in dependentRequired |
|
197
|
|
|
|
|
|
|
|
|
198
|
179
|
|
|
|
|
580
|
foreach my $index (0..$schema->{dependencies}{$property}->$#*) { |
|
199
|
|
|
|
|
|
|
$valid = E({ %$state, _keyword_path_suffix => [ $property, $index ] }, 'element #%d is not a string', $index) |
|
200
|
205
|
50
|
|
|
|
560
|
if not is_type('string', $schema->{dependencies}{$property}[$index]); |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
$valid = E({ %$state, _keyword_path_suffix => $property }, 'elements are not unique') |
|
204
|
179
|
50
|
|
|
|
616
|
if not is_elements_unique($schema->{dependencies}{$property}); |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$valid = E($state, '"dependencies" array for %s is empty', $property) |
|
207
|
179
|
50
|
66
|
|
|
714
|
if $state->{specification_version} eq 'draft4' and not $schema->{dependencies}{$property}->@*; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
else { |
|
210
|
|
|
|
|
|
|
# as in dependentSchemas |
|
211
|
280
|
50
|
|
|
|
1513
|
$valid = 0 if not $class->traverse_property_schema($schema, $state, $property); |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
} |
|
214
|
315
|
|
|
|
|
983
|
return $valid; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
316
|
|
|
316
|
|
556
|
sub _eval_keyword_dependencies ($class, $data, $schema, $state) { |
|
|
316
|
|
|
|
|
586
|
|
|
|
316
|
|
|
|
|
582
|
|
|
|
316
|
|
|
|
|
515
|
|
|
|
316
|
|
|
|
|
500
|
|
|
|
316
|
|
|
|
|
508
|
|
|
218
|
316
|
100
|
|
|
|
949
|
return 1 if not is_type('object', $data); |
|
219
|
|
|
|
|
|
|
|
|
220
|
252
|
|
|
|
|
457
|
my $valid = 1; |
|
221
|
252
|
|
|
|
|
1217
|
foreach my $property (sort keys $schema->{dependencies}->%*) { |
|
222
|
396
|
100
|
|
|
|
1085
|
next if not exists $data->{$property}; |
|
223
|
|
|
|
|
|
|
|
|
224
|
171
|
100
|
|
|
|
598
|
if (is_type('array', $schema->{dependencies}{$property})) { |
|
225
|
|
|
|
|
|
|
# as in dependentRequired |
|
226
|
65
|
100
|
|
|
|
403
|
if (my @missing = grep !exists($data->{$_}), $schema->{dependencies}{$property}->@*) { |
|
227
|
37
|
100
|
|
|
|
528
|
$valid = E({ %$state, _keyword_path_suffix => $property }, |
|
228
|
|
|
|
|
|
|
'object is missing propert%s: %s', @missing > 1 ? 'ies' : 'y', join(', ', @missing)); |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
else { |
|
232
|
|
|
|
|
|
|
# as in dependentSchemas |
|
233
|
106
|
100
|
|
|
|
883
|
if ($class->eval($data, $schema->{dependencies}{$property}, |
|
234
|
|
|
|
|
|
|
+{ %$state, keyword_path => jsonp($state->{keyword_path}, 'dependencies', $property) })) { |
|
235
|
24
|
|
|
|
|
208
|
next; |
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
|
|
238
|
82
|
|
|
|
|
538
|
$valid = 0; |
|
239
|
82
|
100
|
|
|
|
333
|
last if $state->{short_circuit}; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
252
|
100
|
|
|
|
807
|
return E($state, 'not all dependencies are satisfied') if not $valid; |
|
244
|
134
|
|
|
|
|
402
|
return 1; |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
443
|
|
|
443
|
|
2313
|
sub _traverse_keyword_prefixItems { shift->traverse_array_schemas(@_) } |
|
248
|
|
|
|
|
|
|
|
|
249
|
441
|
|
|
441
|
|
10593
|
sub _eval_keyword_prefixItems { goto \&_eval_keyword__items_array_schemas } |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# array- or schema-based before draft2020-12; schema-based only for draft2020-12+ |
|
252
|
1727
|
|
|
1727
|
|
3641
|
sub _traverse_keyword_items ($class, $schema, $state) { |
|
|
1727
|
|
|
|
|
3110
|
|
|
|
1727
|
|
|
|
|
2918
|
|
|
|
1727
|
|
|
|
|
2485
|
|
|
|
1727
|
|
|
|
|
2467
|
|
|
253
|
1727
|
100
|
|
|
|
6425
|
if (ref $schema->{items} eq 'ARRAY') { |
|
254
|
|
|
|
|
|
|
return E($state, 'array form of "items" not supported in %s', $state->{specification_version}) |
|
255
|
938
|
100
|
|
|
|
5312
|
if $state->{specification_version} !~ /^draft(?:[467]|2019-09)\z/; |
|
256
|
|
|
|
|
|
|
|
|
257
|
936
|
|
|
|
|
4547
|
return $class->traverse_array_schemas($schema, $state); |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
|
|
260
|
789
|
|
|
|
|
3768
|
$class->traverse_subschema($schema, $state); |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
1956
|
|
|
1956
|
|
15678
|
sub _eval_keyword_items ($class, $data, $schema, $state) { |
|
|
1956
|
|
|
|
|
3341
|
|
|
|
1956
|
|
|
|
|
3131
|
|
|
|
1956
|
|
|
|
|
3034
|
|
|
|
1956
|
|
|
|
|
3000
|
|
|
|
1956
|
|
|
|
|
2896
|
|
|
264
|
1956
|
100
|
|
|
|
9448
|
goto \&_eval_keyword__items_array_schemas if ref $schema->{items} eq 'ARRAY'; |
|
265
|
971
|
|
|
|
|
4373
|
goto \&_eval_keyword__items_schema; |
|
266
|
|
|
|
|
|
|
} |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
# pre-draft2020-12 only |
|
269
|
342
|
|
|
342
|
|
1392
|
sub _traverse_keyword_additionalItems { shift->traverse_subschema(@_) } |
|
270
|
|
|
|
|
|
|
|
|
271
|
398
|
|
|
398
|
|
3321
|
sub _eval_keyword_additionalItems ($class, $data, $schema, $state) { |
|
|
398
|
|
|
|
|
570
|
|
|
|
398
|
|
|
|
|
557
|
|
|
|
398
|
|
|
|
|
587
|
|
|
|
398
|
|
|
|
|
628
|
|
|
|
398
|
|
|
|
|
478
|
|
|
272
|
398
|
100
|
|
|
|
1133
|
return 1 if not exists $state->{_last_items_index}; |
|
273
|
353
|
|
|
|
|
1247
|
goto \&_eval_keyword__items_schema; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# "prefixItems" (draft 2020-12), array-based "items" (pre-draft2020-12)) |
|
277
|
1426
|
|
|
1426
|
|
2582
|
sub _eval_keyword__items_array_schemas ($class, $data, $schema, $state) { |
|
|
1426
|
|
|
|
|
2481
|
|
|
|
1426
|
|
|
|
|
2486
|
|
|
|
1426
|
|
|
|
|
2184
|
|
|
|
1426
|
|
|
|
|
2158
|
|
|
|
1426
|
|
|
|
|
2073
|
|
|
278
|
1426
|
100
|
|
|
|
4509
|
return 1 if not is_type('array', $data); |
|
279
|
|
|
|
|
|
|
|
|
280
|
1241
|
|
|
|
|
2164
|
my $valid = 1; |
|
281
|
|
|
|
|
|
|
|
|
282
|
1241
|
|
|
|
|
4203
|
foreach my $idx (0 .. $data->$#*) { |
|
283
|
2267
|
100
|
|
|
|
9160
|
last if $idx > $schema->{$state->{keyword}}->$#*; |
|
284
|
1877
|
|
|
|
|
4404
|
$state->{_last_items_index} = $idx; |
|
285
|
|
|
|
|
|
|
|
|
286
|
1877
|
100
|
|
|
|
6237
|
if (is_type('boolean', $schema->{$state->{keyword}}[$idx])) { |
|
|
|
100
|
|
|
|
|
|
|
287
|
339
|
100
|
|
|
|
1898
|
next if $schema->{$state->{keyword}}[$idx]; |
|
288
|
|
|
|
|
|
|
$valid = E({ %$state, data_path => $state->{data_path}.'/'.$idx, |
|
289
|
113
|
|
|
|
|
2836
|
_keyword_path_suffix => $idx, collect_annotations => $state->{collect_annotations} & ~1 }, |
|
290
|
|
|
|
|
|
|
'item not permitted'); |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
elsif ($class->eval($data->[$idx], $schema->{$state->{keyword}}[$idx], |
|
293
|
|
|
|
|
|
|
+{ %$state, data_path => $state->{data_path}.'/'.$idx, |
|
294
|
|
|
|
|
|
|
keyword_path => $state->{keyword_path}.'/'.$state->{keyword}.'/'.$idx, |
|
295
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
296
|
1435
|
|
|
|
|
10296
|
next; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
|
|
|
|
|
|
|
|
299
|
216
|
|
|
|
|
1503
|
$valid = 0; |
|
300
|
|
|
|
|
|
|
last if $state->{short_circuit} and not exists $schema->{ |
|
301
|
|
|
|
|
|
|
$state->{keyword} eq 'prefixItems' ? 'items' |
|
302
|
216
|
50
|
100
|
|
|
2016
|
: $state->{keyword} eq 'items' ? 'additionalItems' : die |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
}; |
|
304
|
|
|
|
|
|
|
} |
|
305
|
|
|
|
|
|
|
|
|
306
|
1241
|
100
|
|
|
|
4069
|
if ($state->{defaults}) { |
|
307
|
9
|
|
|
|
|
41
|
foreach my $idx ($data->$#*+1 .. $schema->{$state->{keyword}}->$#*) { |
|
308
|
|
|
|
|
|
|
$state->{defaults}{$state->{data_path}.'/'.$idx} = $schema->{$state->{keyword}}[$idx]{default} |
|
309
|
|
|
|
|
|
|
if $valid and ref $schema->{$state->{keyword}}[$idx] eq 'HASH' |
|
310
|
9
|
100
|
66
|
|
|
132
|
and exists $schema->{$state->{keyword}}[$idx]{default}; |
|
|
|
|
66
|
|
|
|
|
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
} |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
A($state, $state->{_last_items_index} == $data->$#* ? true : $state->{_last_items_index}) |
|
315
|
1241
|
100
|
|
|
|
8706
|
if exists $state->{_last_items_index}; |
|
|
|
100
|
|
|
|
|
|
|
316
|
1241
|
100
|
|
|
|
3071
|
return E($state, 'not all items are valid') if not $valid; |
|
317
|
1030
|
|
|
|
|
3179
|
return 1; |
|
318
|
|
|
|
|
|
|
} |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
# schema-based items (all drafts), and additionalItems (up to and including draft2019-09) |
|
321
|
1324
|
|
|
1324
|
|
2235
|
sub _eval_keyword__items_schema ($class, $data, $schema, $state) { |
|
|
1324
|
|
|
|
|
2217
|
|
|
|
1324
|
|
|
|
|
1883
|
|
|
|
1324
|
|
|
|
|
1802
|
|
|
|
1324
|
|
|
|
|
1823
|
|
|
|
1324
|
|
|
|
|
1726
|
|
|
322
|
1324
|
100
|
|
|
|
3619
|
return 1 if not is_type('array', $data); |
|
323
|
1182
|
100
|
100
|
|
|
6071
|
return 1 if ($state->{_last_items_index}//-1) == $data->$#*; |
|
324
|
|
|
|
|
|
|
|
|
325
|
813
|
|
|
|
|
1379
|
my $valid = 1; |
|
326
|
|
|
|
|
|
|
|
|
327
|
813
|
|
100
|
|
|
4357
|
foreach my $idx (($state->{_last_items_index}//-1)+1 .. $data->$#*) { |
|
328
|
1337
|
100
|
|
|
|
4900
|
if (is_type('boolean', $schema->{$state->{keyword}})) { |
|
329
|
160
|
100
|
|
|
|
856
|
next if $schema->{$state->{keyword}}; |
|
330
|
|
|
|
|
|
|
$valid = E({ %$state, data_path => $state->{data_path}.'/'.$idx }, |
|
331
|
|
|
|
|
|
|
'%sitem not permitted', |
|
332
|
120
|
100
|
100
|
|
|
3300
|
exists $schema->{prefixItems} || $state->{keyword} eq 'additionalItems' ? 'additional ' : ''); |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
else { |
|
335
|
1177
|
100
|
|
|
|
22266
|
if ($class->eval($data->[$idx], $schema->{$state->{keyword}}, |
|
336
|
|
|
|
|
|
|
+{ %$state, data_path => $state->{data_path}.'/'.$idx, |
|
337
|
|
|
|
|
|
|
keyword_path => $state->{keyword_path}.'/'.$state->{keyword}, |
|
338
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
339
|
814
|
|
|
|
|
5413
|
next; |
|
340
|
|
|
|
|
|
|
} |
|
341
|
|
|
|
|
|
|
|
|
342
|
358
|
|
|
|
|
2377
|
$valid = 0; |
|
343
|
|
|
|
|
|
|
} |
|
344
|
478
|
100
|
|
|
|
2456
|
last if $state->{short_circuit}; |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
|
|
347
|
808
|
|
|
|
|
2625
|
$state->{_last_items_index} = $data->$#*; |
|
348
|
|
|
|
|
|
|
|
|
349
|
808
|
|
|
|
|
2793
|
A($state, true); |
|
350
|
|
|
|
|
|
|
return E($state, 'subschema is not valid against all %sitems', |
|
351
|
808
|
100
|
|
|
|
2761
|
$state->{keyword} eq 'additionalItems' ? 'additional ' : '') if not $valid; |
|
|
|
100
|
|
|
|
|
|
|
352
|
407
|
|
|
|
|
4751
|
return 1; |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
|
|
355
|
815
|
|
|
815
|
|
4638
|
sub _traverse_keyword_contains { shift->traverse_subschema(@_) } |
|
356
|
|
|
|
|
|
|
|
|
357
|
748
|
|
|
748
|
|
1642
|
sub _eval_keyword_contains ($class, $data, $schema, $state) { |
|
|
748
|
|
|
|
|
1628
|
|
|
|
748
|
|
|
|
|
1443
|
|
|
|
748
|
|
|
|
|
1291
|
|
|
|
748
|
|
|
|
|
1368
|
|
|
|
748
|
|
|
|
|
1149
|
|
|
358
|
748
|
100
|
|
|
|
2398
|
return 1 if not is_type('array', $data); |
|
359
|
|
|
|
|
|
|
|
|
360
|
562
|
|
|
|
|
1798
|
$state->{_num_contains} = 0; |
|
361
|
562
|
|
|
|
|
1000
|
my (@errors, @valid); |
|
362
|
|
|
|
|
|
|
|
|
363
|
562
|
|
|
|
|
2099
|
foreach my $idx (0 .. $data->$#*) { |
|
364
|
783
|
100
|
|
|
|
14737
|
if ($class->eval($data->[$idx], $schema->{contains}, |
|
365
|
|
|
|
|
|
|
+{ %$state, errors => \@errors, |
|
366
|
|
|
|
|
|
|
data_path => $state->{data_path}.'/'.$idx, |
|
367
|
|
|
|
|
|
|
keyword_path => $state->{keyword_path}.'/contains', |
|
368
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
369
|
454
|
|
|
|
|
2501
|
++$state->{_num_contains}; |
|
370
|
454
|
|
|
|
|
1111
|
push @valid, $idx; |
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
last if $state->{short_circuit} |
|
373
|
|
|
|
|
|
|
# must continue until maxContains fails, but once it does we are guaranteed to be invalid, |
|
374
|
|
|
|
|
|
|
# so can always stop evaluating immediately |
|
375
|
|
|
|
|
|
|
and (exists $schema->{maxContains} and $state->{_num_contains} > $schema->{maxContains}) |
|
376
|
|
|
|
|
|
|
# once minContains succeeds, we can stop evaluating if no unevaluatedItems present |
|
377
|
|
|
|
|
|
|
# (but only draft2020-12 collects annotations for "contains" evaluations) |
|
378
|
|
|
|
|
|
|
or (not exists $schema->{maxContains} |
|
379
|
|
|
|
|
|
|
and (not $state->{collect_annotations} or $state->{specification_version} ne 'draft2020-12') |
|
380
|
454
|
100
|
100
|
|
|
7032
|
and $state->{_num_contains} >= ($schema->{minContains}//1)); |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
381
|
|
|
|
|
|
|
} |
|
382
|
|
|
|
|
|
|
} |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
# note: no items contained is only valid when minContains is explicitly 0 |
|
385
|
562
|
100
|
66
|
|
|
4431
|
if (not $state->{_num_contains} |
|
|
|
|
66
|
|
|
|
|
|
386
|
|
|
|
|
|
|
and (($schema->{minContains}//1) > 0 or $state->{specification_version} =~ /^draft[467]\z/)) { |
|
387
|
217
|
|
|
|
|
657
|
push $state->{errors}->@*, @errors; |
|
388
|
217
|
|
|
|
|
709
|
return E($state, 'subschema is not valid against any item'); |
|
389
|
|
|
|
|
|
|
} |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
# only draft2020-12 and later can produce annotations |
|
392
|
345
|
100
|
|
|
|
2931
|
A($state, @valid == @$data ? true : \@valid) if $state->{specification_version} !~ /^draft(?:[467]|2019-09)\z/; |
|
|
|
100
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
|
|
394
|
345
|
|
|
|
|
664
|
my $valid = 1; |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
# 'maxContains' and 'minContains' are owned by the Validation vocabulary, but do nothing if the |
|
397
|
|
|
|
|
|
|
# Applicator vocabulary is omitted and depend on the result of 'contains', so they are implemented |
|
398
|
|
|
|
|
|
|
# here, to be evaluated after 'contains' |
|
399
|
345
|
100
|
66
|
|
|
2782
|
if ($state->{specification_version} !~ /^draft[467]\z/ |
|
400
|
|
|
|
|
|
|
and grep $_ eq 'JSON::Schema::Modern::Vocabulary::Validation', $state->{vocabularies}->@*) { |
|
401
|
|
|
|
|
|
|
$valid = E($state, 'array contains more than %d matching item%s', $schema->{maxContains}, $schema->{maxContains} != 1 ? 's' : '') |
|
402
|
277
|
100
|
100
|
|
|
1408
|
if exists $schema->{maxContains} and $state->{_num_contains} > $schema->{maxContains}; |
|
|
|
100
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
$valid = E($state, 'array contains fewer than %d matching item%s', $schema->{minContains}, $schema->{minContains} != 1 ? 's' : '') && $valid |
|
404
|
277
|
100
|
33
|
|
|
1538
|
if exists $schema->{minContains} and $state->{_num_contains} < $schema->{minContains}; |
|
|
|
|
100
|
|
|
|
|
|
405
|
|
|
|
|
|
|
} |
|
406
|
|
|
|
|
|
|
|
|
407
|
345
|
|
|
|
|
1643
|
return $valid; |
|
408
|
|
|
|
|
|
|
} |
|
409
|
|
|
|
|
|
|
|
|
410
|
3846
|
|
|
3846
|
|
19023
|
sub _traverse_keyword_properties { shift->traverse_object_schemas(@_) } |
|
411
|
|
|
|
|
|
|
|
|
412
|
4189
|
|
|
4189
|
|
20793
|
sub _eval_keyword_properties ($class, $data, $schema, $state) { |
|
|
4189
|
|
|
|
|
7722
|
|
|
|
4189
|
|
|
|
|
7417
|
|
|
|
4189
|
|
|
|
|
7064
|
|
|
|
4189
|
|
|
|
|
6897
|
|
|
|
4189
|
|
|
|
|
6338
|
|
|
413
|
4189
|
100
|
|
|
|
12804
|
return 1 if not is_type('object', $data); |
|
414
|
|
|
|
|
|
|
|
|
415
|
3908
|
|
|
|
|
6676
|
my $valid = 1; |
|
416
|
3908
|
|
|
|
|
6324
|
my @properties; |
|
417
|
3908
|
|
|
|
|
23478
|
foreach my $property (sort keys $schema->{properties}->%*) { |
|
418
|
11113
|
100
|
100
|
|
|
34570
|
if (not exists $data->{$property} and $state->{defaults}) { |
|
419
|
|
|
|
|
|
|
$state->{defaults}{jsonp($state->{data_path}, $property)} = $schema->{properties}{$property}{default} |
|
420
|
|
|
|
|
|
|
if $valid and $state->{defaults} |
|
421
|
|
|
|
|
|
|
and ref $schema->{properties}{$property} eq 'HASH' |
|
422
|
10
|
100
|
66
|
|
|
115
|
and exists $schema->{properties}{$property}{default}; |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
423
|
|
|
|
|
|
|
|
|
424
|
10
|
|
|
|
|
21
|
next; |
|
425
|
|
|
|
|
|
|
} |
|
426
|
|
|
|
|
|
|
|
|
427
|
11103
|
100
|
|
|
|
22391
|
next if not exists $data->{$property}; |
|
428
|
3065
|
|
|
|
|
6759
|
push @properties, $property; |
|
429
|
|
|
|
|
|
|
|
|
430
|
3065
|
100
|
|
|
|
10156
|
if (is_type('boolean', $schema->{properties}{$property})) { |
|
431
|
431
|
100
|
|
|
|
2500
|
next if $schema->{properties}{$property}; |
|
432
|
118
|
|
|
|
|
1828
|
$valid = E({ %$state, data_path => jsonp($state->{data_path}, $property), |
|
433
|
|
|
|
|
|
|
_keyword_path_suffix => $property }, 'property not permitted'); |
|
434
|
|
|
|
|
|
|
} |
|
435
|
|
|
|
|
|
|
else { |
|
436
|
2634
|
100
|
|
|
|
21806
|
if ($class->eval($data->{$property}, $schema->{properties}{$property}, |
|
437
|
|
|
|
|
|
|
+{ %$state, data_path => jsonp($state->{data_path}, $property), |
|
438
|
|
|
|
|
|
|
keyword_path => jsonp($state->{keyword_path}, 'properties', $property), |
|
439
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
440
|
1886
|
|
|
|
|
13722
|
next; |
|
441
|
|
|
|
|
|
|
} |
|
442
|
|
|
|
|
|
|
|
|
443
|
742
|
|
|
|
|
5470
|
$valid = 0; |
|
444
|
|
|
|
|
|
|
} |
|
445
|
860
|
100
|
|
|
|
4475
|
last if $state->{short_circuit}; |
|
446
|
|
|
|
|
|
|
} |
|
447
|
|
|
|
|
|
|
|
|
448
|
3902
|
|
|
|
|
18414
|
A($state, \@properties); |
|
449
|
3902
|
100
|
|
|
|
9109
|
return E($state, 'not all properties are valid') if not $valid; |
|
450
|
3084
|
|
|
|
|
9261
|
return 1; |
|
451
|
|
|
|
|
|
|
} |
|
452
|
|
|
|
|
|
|
|
|
453
|
1077
|
|
|
1077
|
|
2503
|
sub _traverse_keyword_patternProperties ($class, $schema, $state) { |
|
|
1077
|
|
|
|
|
2311
|
|
|
|
1077
|
|
|
|
|
2128
|
|
|
|
1077
|
|
|
|
|
1746
|
|
|
|
1077
|
|
|
|
|
1776
|
|
|
454
|
1077
|
100
|
|
|
|
5436
|
return if not $class->traverse_object_schemas($schema, $state); |
|
455
|
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
0+!grep !assert_pattern({ %$state, _keyword_path_suffix => $_ }, $_), |
|
457
|
1076
|
|
|
|
|
12267
|
sort keys $schema->{patternProperties}->%*; |
|
458
|
|
|
|
|
|
|
} |
|
459
|
|
|
|
|
|
|
|
|
460
|
1003
|
|
|
1003
|
|
15665
|
sub _eval_keyword_patternProperties ($class, $data, $schema, $state) { |
|
|
1003
|
|
|
|
|
1975
|
|
|
|
1003
|
|
|
|
|
1910
|
|
|
|
1003
|
|
|
|
|
1649
|
|
|
|
1003
|
|
|
|
|
1503
|
|
|
|
1003
|
|
|
|
|
1513
|
|
|
461
|
1003
|
100
|
|
|
|
3406
|
return 1 if not is_type('object', $data); |
|
462
|
|
|
|
|
|
|
|
|
463
|
815
|
|
|
|
|
1551
|
my $valid = 1; |
|
464
|
815
|
|
|
|
|
1454
|
my @properties; |
|
465
|
815
|
|
|
|
|
3927
|
foreach my $property_pattern (sort keys $schema->{patternProperties}->%*) { |
|
466
|
1157
|
|
|
|
|
19952
|
foreach my $property (sort grep m/(?:$property_pattern)/, keys %$data) { |
|
467
|
761
|
|
|
|
|
2268
|
push @properties, $property; |
|
468
|
761
|
100
|
|
|
|
3026
|
if (is_type('boolean', $schema->{patternProperties}{$property_pattern})) { |
|
469
|
360
|
100
|
|
|
|
2010
|
next if $schema->{patternProperties}{$property_pattern}; |
|
470
|
118
|
|
|
|
|
1667
|
$valid = E({ %$state, data_path => jsonp($state->{data_path}, $property), |
|
471
|
|
|
|
|
|
|
_keyword_path_suffix => $property_pattern }, 'property not permitted'); |
|
472
|
|
|
|
|
|
|
} |
|
473
|
|
|
|
|
|
|
else { |
|
474
|
401
|
100
|
|
|
|
3214
|
if ($class->eval($data->{$property}, $schema->{patternProperties}{$property_pattern}, |
|
475
|
|
|
|
|
|
|
+{ %$state, data_path => jsonp($state->{data_path}, $property), |
|
476
|
|
|
|
|
|
|
keyword_path => jsonp($state->{keyword_path}, 'patternProperties', $property_pattern), |
|
477
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
478
|
260
|
|
|
|
|
2179
|
next; |
|
479
|
|
|
|
|
|
|
} |
|
480
|
|
|
|
|
|
|
|
|
481
|
141
|
|
|
|
|
1035
|
$valid = 0; |
|
482
|
|
|
|
|
|
|
} |
|
483
|
259
|
100
|
|
|
|
1764
|
last if $state->{short_circuit}; |
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
} |
|
486
|
|
|
|
|
|
|
|
|
487
|
815
|
|
|
|
|
6864
|
A($state, [ uniqstr @properties ]); |
|
488
|
815
|
100
|
|
|
|
2699
|
return E($state, 'not all properties are valid') if not $valid; |
|
489
|
580
|
|
|
|
|
1774
|
return 1; |
|
490
|
|
|
|
|
|
|
} |
|
491
|
|
|
|
|
|
|
|
|
492
|
1188
|
|
|
1188
|
|
6163
|
sub _traverse_keyword_additionalProperties { shift->traverse_subschema(@_) } |
|
493
|
|
|
|
|
|
|
|
|
494
|
1148
|
|
|
1148
|
|
12118
|
sub _eval_keyword_additionalProperties ($class, $data, $schema, $state) { |
|
|
1148
|
|
|
|
|
2099
|
|
|
|
1148
|
|
|
|
|
1925
|
|
|
|
1148
|
|
|
|
|
1966
|
|
|
|
1148
|
|
|
|
|
1751
|
|
|
|
1148
|
|
|
|
|
1606
|
|
|
495
|
1148
|
100
|
|
|
|
3225
|
return 1 if not is_type('object', $data); |
|
496
|
|
|
|
|
|
|
|
|
497
|
898
|
|
|
|
|
1561
|
my $valid = 1; |
|
498
|
898
|
|
|
|
|
1518
|
my @properties; |
|
499
|
898
|
|
|
|
|
3517
|
foreach my $property (sort keys %$data) { |
|
500
|
974
|
100
|
100
|
|
|
4068
|
next if exists $schema->{properties} and exists $schema->{properties}{$property}; |
|
501
|
|
|
|
|
|
|
next if exists $schema->{patternProperties} |
|
502
|
763
|
100
|
100
|
|
|
3726
|
and any { $property =~ /(?:$_)/ } keys $schema->{patternProperties}->%*; |
|
|
248
|
|
|
|
|
3116
|
|
|
503
|
|
|
|
|
|
|
|
|
504
|
616
|
|
|
|
|
1448
|
push @properties, $property; |
|
505
|
616
|
100
|
|
|
|
1833
|
if (is_type('boolean', $schema->{additionalProperties})) { |
|
506
|
257
|
100
|
|
|
|
1257
|
next if $schema->{additionalProperties}; |
|
507
|
236
|
|
|
|
|
3157
|
$valid = E({ %$state, data_path => jsonp($state->{data_path}, $property) }, |
|
508
|
|
|
|
|
|
|
'additional property not permitted'); |
|
509
|
|
|
|
|
|
|
} |
|
510
|
|
|
|
|
|
|
else { |
|
511
|
359
|
100
|
|
|
|
2985
|
if ($class->eval($data->{$property}, $schema->{additionalProperties}, |
|
512
|
|
|
|
|
|
|
+{ %$state, data_path => jsonp($state->{data_path}, $property), |
|
513
|
|
|
|
|
|
|
keyword_path => $state->{keyword_path}.'/additionalProperties', |
|
514
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
515
|
210
|
|
|
|
|
1597
|
next; |
|
516
|
|
|
|
|
|
|
} |
|
517
|
|
|
|
|
|
|
|
|
518
|
149
|
|
|
|
|
1012
|
$valid = 0; |
|
519
|
|
|
|
|
|
|
} |
|
520
|
385
|
100
|
|
|
|
2522
|
last if $state->{short_circuit}; |
|
521
|
|
|
|
|
|
|
} |
|
522
|
|
|
|
|
|
|
|
|
523
|
898
|
|
|
|
|
3476
|
A($state, \@properties); |
|
524
|
898
|
100
|
|
|
|
2565
|
return E($state, 'not all additional properties are valid') if not $valid; |
|
525
|
514
|
|
|
|
|
1543
|
return 1; |
|
526
|
|
|
|
|
|
|
} |
|
527
|
|
|
|
|
|
|
|
|
528
|
550
|
|
|
550
|
|
3206
|
sub _traverse_keyword_propertyNames { shift->traverse_subschema(@_) } |
|
529
|
|
|
|
|
|
|
|
|
530
|
489
|
|
|
489
|
|
1154
|
sub _eval_keyword_propertyNames ($class, $data, $schema, $state) { |
|
|
489
|
|
|
|
|
1098
|
|
|
|
489
|
|
|
|
|
1059
|
|
|
|
489
|
|
|
|
|
904
|
|
|
|
489
|
|
|
|
|
871
|
|
|
|
489
|
|
|
|
|
836
|
|
|
531
|
489
|
100
|
|
|
|
1635
|
return 1 if not is_type('object', $data); |
|
532
|
|
|
|
|
|
|
|
|
533
|
337
|
|
|
|
|
746
|
my $valid = 1; |
|
534
|
337
|
|
|
|
|
1495
|
foreach my $property (sort keys %$data) { |
|
535
|
264
|
100
|
|
|
|
2050
|
if ($class->eval($property, $schema->{propertyNames}, |
|
536
|
|
|
|
|
|
|
+{ %$state, data_path => jsonp($state->{data_path}, $property), |
|
537
|
|
|
|
|
|
|
keyword_path => $state->{keyword_path}.'/propertyNames', |
|
538
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
539
|
131
|
|
|
|
|
1079
|
next; |
|
540
|
|
|
|
|
|
|
} |
|
541
|
|
|
|
|
|
|
|
|
542
|
133
|
|
|
|
|
1004
|
$valid = 0; |
|
543
|
133
|
100
|
|
|
|
662
|
last if $state->{short_circuit}; |
|
544
|
|
|
|
|
|
|
} |
|
545
|
|
|
|
|
|
|
|
|
546
|
337
|
100
|
|
|
|
1194
|
return E($state, 'not all property names are valid') if not $valid; |
|
547
|
204
|
|
|
|
|
654
|
return 1; |
|
548
|
|
|
|
|
|
|
} |
|
549
|
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
1; |
|
551
|
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
__END__ |