| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
38
|
|
|
38
|
|
650
|
use strict; |
|
|
38
|
|
|
|
|
72
|
|
|
|
38
|
|
|
|
|
1209
|
|
|
2
|
38
|
|
|
38
|
|
141
|
use warnings; |
|
|
38
|
|
|
|
|
63
|
|
|
|
38
|
|
|
|
|
2451
|
|
|
3
|
|
|
|
|
|
|
package JSON::Schema::Modern::Vocabulary::Unevaluated; |
|
4
|
|
|
|
|
|
|
# vim: set ts=8 sts=2 sw=2 tw=100 et : |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Implementation of the JSON Schema Unevaluated vocabulary |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.635'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
38
|
|
|
38
|
|
475
|
use 5.020; |
|
|
38
|
|
|
|
|
144
|
|
|
10
|
38
|
|
|
38
|
|
181
|
use Moo; |
|
|
38
|
|
|
|
|
117
|
|
|
|
38
|
|
|
|
|
214
|
|
|
11
|
38
|
|
|
38
|
|
11470
|
use strictures 2; |
|
|
38
|
|
|
|
|
256
|
|
|
|
38
|
|
|
|
|
1201
|
|
|
12
|
38
|
|
|
38
|
|
12253
|
use stable 0.031 'postderef'; |
|
|
38
|
|
|
|
|
578
|
|
|
|
38
|
|
|
|
|
251
|
|
|
13
|
38
|
|
|
38
|
|
5597
|
use experimental 'signatures'; |
|
|
38
|
|
|
|
|
72
|
|
|
|
38
|
|
|
|
|
156
|
|
|
14
|
38
|
|
|
38
|
|
1898
|
no autovivification warn => qw(fetch store exists delete); |
|
|
38
|
|
|
|
|
92
|
|
|
|
38
|
|
|
|
|
211
|
|
|
15
|
38
|
|
|
38
|
|
2272
|
use if "$]" >= 5.022, experimental => 're_strict'; |
|
|
38
|
|
|
|
|
81
|
|
|
|
38
|
|
|
|
|
662
|
|
|
16
|
38
|
|
|
38
|
|
2521
|
no if "$]" >= 5.031009, feature => 'indirect'; |
|
|
38
|
|
|
|
|
66
|
|
|
|
38
|
|
|
|
|
2027
|
|
|
17
|
38
|
|
|
38
|
|
172
|
no if "$]" >= 5.033001, feature => 'multidimensional'; |
|
|
38
|
|
|
|
|
62
|
|
|
|
38
|
|
|
|
|
1781
|
|
|
18
|
38
|
|
|
38
|
|
185
|
no if "$]" >= 5.033006, feature => 'bareword_filehandles'; |
|
|
38
|
|
|
|
|
72
|
|
|
|
38
|
|
|
|
|
1827
|
|
|
19
|
38
|
|
|
38
|
|
169
|
no if "$]" >= 5.041009, feature => 'smartmatch'; |
|
|
38
|
|
|
|
|
79
|
|
|
|
38
|
|
|
|
|
1269
|
|
|
20
|
38
|
|
|
38
|
|
148
|
no feature 'switch'; |
|
|
38
|
|
|
|
|
66
|
|
|
|
38
|
|
|
|
|
893
|
|
|
21
|
38
|
|
|
38
|
|
143
|
use List::Util 'max'; |
|
|
38
|
|
|
|
|
66
|
|
|
|
38
|
|
|
|
|
2744
|
|
|
22
|
38
|
|
|
38
|
|
190
|
use if "$]" < 5.041010, 'List::Util' => 'any'; |
|
|
38
|
|
|
|
|
76
|
|
|
|
38
|
|
|
|
|
1407
|
|
|
23
|
38
|
|
|
38
|
|
166
|
use if "$]" >= 5.041010, experimental => 'keyword_any'; |
|
|
38
|
|
|
|
|
80
|
|
|
|
38
|
|
|
|
|
460
|
|
|
24
|
38
|
|
|
38
|
|
2619
|
use JSON::Schema::Modern::Utilities qw(is_type jsonp local_annotations E A abort true); |
|
|
38
|
|
|
|
|
85
|
|
|
|
38
|
|
|
|
|
2468
|
|
|
25
|
38
|
|
|
38
|
|
171
|
use namespace::clean; |
|
|
38
|
|
|
|
|
69
|
|
|
|
38
|
|
|
|
|
305
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
with 'JSON::Schema::Modern::Vocabulary'; |
|
28
|
|
|
|
|
|
|
|
|
29
|
22
|
|
|
22
|
0
|
32
|
sub vocabulary ($class) { |
|
|
22
|
|
|
|
|
38
|
|
|
|
22
|
|
|
|
|
33
|
|
|
30
|
22
|
|
|
|
|
116
|
'https://json-schema.org/draft/2020-12/vocab/unevaluated' => 'draft2020-12'; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
0
|
0
|
sub evaluation_order ($class) { 7 } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# This vocabulary should be evaluated after the Applicator vocabulary. |
|
36
|
62
|
|
|
62
|
0
|
286
|
sub keywords ($class, $spec_version) { |
|
|
62
|
|
|
|
|
118
|
|
|
|
62
|
|
|
|
|
96
|
|
|
|
62
|
|
|
|
|
103
|
|
|
37
|
62
|
100
|
|
|
|
281
|
die 'Unevaluated not implemented in '.$spec_version if $spec_version =~ /^draft(?:[467]|2019-09)\z/; |
|
38
|
58
|
|
|
|
|
591
|
qw(unevaluatedItems unevaluatedProperties); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
587
|
|
|
587
|
|
1084
|
sub _traverse_keyword_unevaluatedItems ($class, $schema, $state) { |
|
|
587
|
|
|
|
|
1078
|
|
|
|
587
|
|
|
|
|
934
|
|
|
|
587
|
|
|
|
|
881
|
|
|
|
587
|
|
|
|
|
860
|
|
|
42
|
587
|
|
|
|
|
2074
|
$class->traverse_subschema($schema, $state); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
554
|
|
|
554
|
|
937
|
sub _eval_keyword_unevaluatedItems ($class, $data, $schema, $state) { |
|
|
554
|
|
|
|
|
1024
|
|
|
|
554
|
|
|
|
|
956
|
|
|
|
554
|
|
|
|
|
883
|
|
|
|
554
|
|
|
|
|
934
|
|
|
|
554
|
|
|
|
|
802
|
|
|
46
|
554
|
100
|
|
|
|
1474
|
return 1 if not is_type('array', $data); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# these should never happen |
|
49
|
|
|
|
|
|
|
die '"unevaluatedItems" keyword present, but annotation collection is disabled' |
|
50
|
420
|
50
|
|
|
|
1297
|
if not $state->{collect_annotations}; |
|
51
|
|
|
|
|
|
|
|
|
52
|
420
|
|
|
|
|
1168
|
my @annotations = local_annotations($state); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# a relevant keyword already produced a 'true' annotation at this location |
|
55
|
|
|
|
|
|
|
my @boolean_annotation_keywords = |
|
56
|
420
|
100
|
|
|
|
1748
|
$state->{specification_version} eq 'draft2019-09' ? qw(items additionalItems unevaluatedItems) |
|
57
|
|
|
|
|
|
|
: qw(prefixItems items contains unevaluatedItems); |
|
58
|
420
|
|
|
|
|
634
|
my %bools; @bools{@boolean_annotation_keywords} = (1)x@boolean_annotation_keywords; |
|
|
420
|
|
|
|
|
1897
|
|
|
59
|
|
|
|
|
|
|
return 1 |
|
60
|
420
|
100
|
66
|
|
|
941
|
if any { $bools{$_->{keyword}} && is_type('boolean', $_->{annotation}) && $_->{annotation} } |
|
|
264
|
100
|
|
|
|
1425
|
|
|
61
|
|
|
|
|
|
|
@annotations; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# otherwise, evaluate at every instance item greater than the max of all 'prefixItems'/numeric |
|
64
|
|
|
|
|
|
|
# 'items' annotations that isn't in a 'contains' annotation |
|
65
|
317
|
100
|
|
|
|
891
|
my $max_index_annotation_keyword = $state->{specification_version} eq 'draft2019-09' ? 'items' : 'prefixItems'; |
|
66
|
|
|
|
|
|
|
my $last_index = max(-1, grep is_type('integer', $_), |
|
67
|
317
|
100
|
|
|
|
1246
|
map +($_->{keyword} eq $max_index_annotation_keyword ? $_->{annotation} : ()), @annotations); |
|
68
|
|
|
|
|
|
|
|
|
69
|
317
|
100
|
|
|
|
1082
|
return 1 if $last_index == $data->$#*; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my @contains_annotation_indexes = $state->{specification_version} eq 'draft2019-09' ? () |
|
72
|
223
|
100
|
|
|
|
860
|
: map +($_->{keyword} eq 'contains' ? $_->{annotation}->@* : ()), @annotations; |
|
|
|
100
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
223
|
|
|
|
|
380
|
my $valid = 1; |
|
75
|
223
|
|
|
|
|
829
|
foreach my $idx ($last_index+1 .. $data->$#*) { |
|
76
|
312
|
100
|
|
|
|
718
|
next if any { $idx == $_ } @contains_annotation_indexes; |
|
|
183
|
|
|
|
|
326
|
|
|
77
|
256
|
100
|
|
|
|
664
|
if (is_type('boolean', $schema->{unevaluatedItems})) { |
|
78
|
194
|
100
|
|
|
|
741
|
next if $schema->{unevaluatedItems}; |
|
79
|
174
|
|
|
|
|
3266
|
$valid = E({ %$state, data_path => $state->{data_path}.'/'.$idx }, |
|
80
|
|
|
|
|
|
|
'additional item not permitted') |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else { |
|
83
|
62
|
100
|
|
|
|
1027
|
if ($class->eval($data->[$idx], $schema->{unevaluatedItems}, |
|
84
|
|
|
|
|
|
|
+{ %$state, data_path => $state->{data_path}.'/'.$idx, |
|
85
|
|
|
|
|
|
|
keyword_path => $state->{keyword_path}.'/unevaluatedItems', |
|
86
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
87
|
44
|
|
|
|
|
293
|
next; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
18
|
|
|
|
|
116
|
$valid = 0; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
192
|
100
|
|
|
|
1402
|
last if $state->{short_circuit}; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
223
|
|
|
|
|
804
|
A($state, true); |
|
96
|
223
|
100
|
|
|
|
674
|
return E($state, 'subschema is not valid against all additional items') if not $valid; |
|
97
|
40
|
|
|
|
|
184
|
return 1; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
994
|
|
|
994
|
|
1678
|
sub _traverse_keyword_unevaluatedProperties ($class, $schema, $state) { |
|
|
994
|
|
|
|
|
1658
|
|
|
|
994
|
|
|
|
|
1545
|
|
|
|
994
|
|
|
|
|
1517
|
|
|
|
994
|
|
|
|
|
1570
|
|
|
101
|
994
|
|
|
|
|
3817
|
$class->traverse_subschema($schema, $state); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
932
|
|
|
932
|
|
1569
|
sub _eval_keyword_unevaluatedProperties ($class, $data, $schema, $state) { |
|
|
932
|
|
|
|
|
1521
|
|
|
|
932
|
|
|
|
|
1766
|
|
|
|
932
|
|
|
|
|
1258
|
|
|
|
932
|
|
|
|
|
1204
|
|
|
|
932
|
|
|
|
|
1244
|
|
|
105
|
932
|
100
|
|
|
|
2392
|
return 1 if not is_type('object', $data); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# these should never happen |
|
108
|
|
|
|
|
|
|
die '"unevaluatedProperties" keyword present, but annotation collection is disabled' |
|
109
|
819
|
50
|
|
|
|
2388
|
if not $state->{collect_annotations}; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my @evaluated_properties = map { |
|
112
|
819
|
|
|
|
|
2245
|
my $keyword = $_->{keyword}; |
|
|
707
|
|
|
|
|
1300
|
|
|
113
|
|
|
|
|
|
|
(grep $keyword eq $_, qw(properties additionalProperties patternProperties unevaluatedProperties)) |
|
114
|
707
|
100
|
|
|
|
3133
|
? $_->{annotation}->@* : (); |
|
115
|
|
|
|
|
|
|
} local_annotations($state); |
|
116
|
|
|
|
|
|
|
|
|
117
|
819
|
|
|
|
|
1260
|
my $valid = 1; |
|
118
|
819
|
|
|
|
|
1154
|
my @properties; |
|
119
|
819
|
|
|
|
|
2938
|
foreach my $property (sort keys %$data) { |
|
120
|
1053
|
100
|
|
|
|
2421
|
next if any { $_ eq $property } @evaluated_properties; |
|
|
939
|
|
|
|
|
2310
|
|
|
121
|
485
|
|
|
|
|
1136
|
push @properties, $property; |
|
122
|
|
|
|
|
|
|
|
|
123
|
485
|
100
|
|
|
|
1239
|
if (is_type('boolean', $schema->{unevaluatedProperties})) { |
|
124
|
450
|
100
|
|
|
|
1900
|
next if $schema->{unevaluatedProperties}; |
|
125
|
317
|
|
|
|
|
3611
|
$valid = E({ %$state, data_path => jsonp($state->{data_path}, $property) }, |
|
126
|
|
|
|
|
|
|
'additional property not permitted'); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
else { |
|
129
|
35
|
100
|
|
|
|
228
|
if ($class->eval($data->{$property}, $schema->{unevaluatedProperties}, |
|
130
|
|
|
|
|
|
|
+{ %$state, data_path => jsonp($state->{data_path}, $property), |
|
131
|
|
|
|
|
|
|
keyword_path => $state->{keyword_path}.'/unevaluatedProperties', |
|
132
|
|
|
|
|
|
|
collect_annotations => $state->{collect_annotations} & ~1 })) { |
|
133
|
22
|
|
|
|
|
166
|
next; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
13
|
|
|
|
|
106
|
$valid = 0; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
330
|
100
|
|
|
|
2390
|
last if $state->{short_circuit}; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
819
|
|
|
|
|
2917
|
A($state, \@properties); |
|
142
|
819
|
100
|
|
|
|
2055
|
return E($state, 'not all additional properties are valid') if not $valid; |
|
143
|
511
|
|
|
|
|
1638
|
return 1; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
__END__ |