Debian Codegraph @

src/keywords/unevaluated_items.rs

raw symbols SCIP
1 //! Implementation of the `unevaluatedItems` keyword.
2 //!
3 //! This keyword validates array items that were not evaluated by other keywords like
4 //! `items`, `prefixItems`, `contains`, or nested schemas in combinators (`allOf`, `anyOf`, `oneOf`),
5 //! conditionals, and references.
6 //!
7 //! The implementation eagerly compiles a recursive `ItemsValidators` structure during
8 //! schema compilation, using `Shared<OnceLock>` for circular reference handling.
9 use referencingrust-analyzer cargo referencing 0.37.4 crate/::Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#;
10 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{Maprust-analyzer cargo serde_json 1.0.145 map/Map#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#};
11 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#;
12
13 use craterust-analyzer cargo jsonschema 0.37.4 crate/::{
14 compilerrust-analyzer cargo jsonschema 0.37.4 compiler/,
15 evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/::ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#,
16 noderust-analyzer cargo jsonschema 0.37.4 node/::SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
17 pathsrust-analyzer cargo jsonschema 0.37.4 paths/::{LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#},
18 threadrust-analyzer cargo jsonschema 0.37.4 thread/::Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#,
19 validatorrust-analyzer cargo jsonschema 0.37.4 validator/::{EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#, Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#, ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#},
20 ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#,
21 };
22
23 use superrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#;
24
25 /// Lazy items validators that are compiled on first access.
26 /// Used for $recursiveRef and circular references to handle cycles during compilation.
27 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) type PendingItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/PendingItemsValidators# = Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#<OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#>>;
28
29 /// Holds compiled validators for items evaluation in unevaluatedItems.
30 /// This structure is built during schema compilation and used during validation.
31 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
32 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators# {
33 /// Validator from "unevaluatedItems" keyword itself
34 unevaluatedrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#unevaluated.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#>,
35 /// Validator from "contains" keyword
36 containsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#contains.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#>,
37 /// Reference validators from "$ref" keyword
38 ref_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#ref_.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<RefValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/RefValidator#>,
39 /// Reference validators from "$dynamicRef" keyword (Draft 2020-12+)
40 dynamic_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#dynamic_ref.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#>>,
41 /// Validators from "$recursiveRef" keyword (Draft 2019-09 only)
42 recursive_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#recursive_ref.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PendingItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/PendingItemsValidators#>,
43 /// Items limit - for Draft 2019-09 "items" keyword behavior
44 /// If present, marks first N items as evaluated
45 items_limitrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#items_limit.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
46 /// Items schema present - for Draft 2020-12+ "items" keyword
47 /// If true, marks ALL items as evaluated
48 items_allrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#items_all.: bool,
49 /// Prefix items count - from "prefixItems" keyword
50 prefix_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#prefix_items.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
51 /// Conditional validators from "if/then/else" keywords
52 conditionalrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#conditional.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<ConditionalValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#>>,
53 /// Validators from "allOf" keyword
54 all_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#all_of.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#)>>,
55 /// Validators from "anyOf" keyword
56 any_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#any_of.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#)>>,
57 /// Validators from "oneOf" keyword
58 one_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#one_of.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#)>>,
59 }
60
61 /// Reference validator - wraps `ItemsValidators`
62 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
63 struct RefValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/RefValidator#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#>);
64
65 /// Conditional validators from "if/then/else" keywords
66 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
67 struct ConditionalValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators# {
68 conditionrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#condition.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
69 if_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#if_.: ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#,
70 then_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#then_.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#>,
71 else_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#else_.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#>,
72 }
73
74 impl ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators# {
75 /// Mark all items that are evaluated by this schema.
76 fn mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(
77 &self,
78 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
79 indexes: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<bool>,
80 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
81 ) {
82 // Early return optimization: if items marks ALL items, no need to check anything else
83 if self.items_allrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#items_all. {
84 // Draft 2020-12+: items keyword marks ALL items as evaluated
85 for idx in indexes.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() {
86 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().idx = true;
87 }
88 return;
89 }
90
91 // Handle $ref first
92 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref_) = &self.ref_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#ref_. {
93 ref_.0rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/RefValidator#0..mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
94 }
95
96 // Handle $recursiveRef (Draft 2019-09 only)
97 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(recursive_ref) = &self.recursive_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#recursive_ref. {
98 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(validators) = recursive_ref.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get().() {
99 validators.mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
100 }
101 }
102
103 // Handle $dynamicRef (Draft 2020-12+)
104 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(dynamic_ref) = &self.dynamic_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#dynamic_ref. {
105 dynamic_ref.mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
106 }
107
108 // Mark items based on items/prefixItems keywords
109 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(limit) = self.items_limitrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#items_limit. {
110 // Draft 2019-09: items (as array) marks first N items
111 for idx in indexes.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(limit) {
112 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().idx = true;
113 }
114 }
115
116 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(limit) = self.prefix_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#prefix_items. {
117 // prefixItems marks first N items
118 for idx in indexes.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(limit) {
119 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().idx = true;
120 }
121 }
122
123 // Early exit if all items are already evaluated
124 if indexes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|&evaluated| evaluated) {
125 return;
126 }
127
128 // Process contains and unevaluatedItems
129 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
130 for (item, is_evaluated) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(indexes.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().()) {
131 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().is_evaluated {
132 continue;
133 }
134 // contains marks items that match
135 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(validator) = &self.containsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#contains. {
136 if validator.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(item, ctx) {
137 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().is_evaluated = true;
138 continue;
139 }
140 }
141 // unevaluatedItems itself can mark items
142 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(validator) = &self.unevaluatedrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#unevaluated. {
143 if validator.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(item, ctx) {
144 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().is_evaluated = true;
145 }
146 }
147 }
148 }
149
150 // Handle conditional
151 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(conditional) = &self.conditionalrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#conditional. {
152 conditional.mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ConditionalValidators]mark_evaluated_indexes().(instance, indexes, ctx);
153 }
154
155 // Handle allOf - each schema that validates successfully marks items
156 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(all_of) = &self.all_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#all_of. {
157 for (validator, item_validators) in all_of {
158 if validator.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) {
159 item_validators.mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
160 }
161 }
162 }
163
164 // Handle anyOf - each schema that validates successfully marks items
165 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(any_of) = &self.any_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#any_of. {
166 for (validator, item_validators) in any_of {
167 if validator.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) {
168 item_validators.mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
169 }
170 }
171 }
172
173 // Handle oneOf - only mark if exactly one schema validates
174 // Optimization: cache validation results to avoid double validation
175 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(one_of) = &self.one_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#one_of. {
176 let results: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = one_of
177 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
178 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(v, _)| v.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx))
179 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
180
181 if results.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|&&valid| valid).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 {
182 for ((_, validators), &is_valid) in one_of.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&results) {
183 if is_valid {
184 validators.mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
185 break;
186 }
187 }
188 }
189 }
190 }
191 }
192
193 impl ConditionalValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators# {
194 fn mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ConditionalValidators]mark_evaluated_indexes().(
195 &self,
196 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
197 indexes: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<bool>,
198 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
199 ) {
200 if self.conditionrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#condition..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) {
201 self.if_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#if_..mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
202 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(then_) = &self.then_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#then_. {
203 then_.mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
204 }
205 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(else_) = &self.else_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#else_. {
206 else_.mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, indexes, ctx);
207 }
208 }
209 }
210
211 /// Compile all items validators for a schema.
212 ///
213 /// Recursively builds the `ItemsValidators` tree by examining all keywords that
214 /// can evaluate items. Handles circular references via pending nodes cached
215 /// by location and schema pointer.
216 fn compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().<'a>(
217 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
218 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
219 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
220 let unevaluated = compile_unevaluatedrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_unevaluated().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
221 let contains = compile_containsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_contains().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
222 let ref_ = compile_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_ref().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
223 let dynamic_ref = compile_dynamic_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_dynamic_ref().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
224 let recursive_ref = compile_recursive_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_recursive_ref().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
225
226 // Determine items behavior based on draft
227 let (items_limit, items_all) = compile_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
228 let prefix_items = compile_prefix_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_prefix_items().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
229
230 let conditional = compile_conditionalrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_conditional().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
231 let all_of = compile_all_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_all_of().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
232 let any_of = compile_any_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_any_of().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
233 let one_of = compile_one_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_one_of().(ctx, parent)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
234
235 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators# {
236 unevaluatedrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#unevaluated.,
237 containsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#contains.,
238 ref_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#ref_.,
239 dynamic_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#dynamic_ref.,
240 recursive_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#recursive_ref.,
241 items_limitrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#items_limit.,
242 items_allrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#items_all.,
243 prefix_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#prefix_items.,
244 conditionalrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#conditional.,
245 all_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#all_of.,
246 any_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#any_of.,
247 one_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#one_of.,
248 })
249 }
250
251 fn compile_unevaluatedrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_unevaluated().<'a>(
252 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
253 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
254 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
255 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(subschema) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("unevaluatedItems") {
256 let unevaluated_ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("unevaluatedItems");
257 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(
258 compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&unevaluated_ctx, unevaluated_ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(subschema))
259 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
260 ))
261 } else {
262 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
263 }
264 }
265
266 fn compile_containsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_contains().<'a>(
267 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
268 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
269 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
270 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(subschema) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("contains") {
271 let contains_ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("contains");
272 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(
273 compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&contains_ctx, contains_ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(subschema))
274 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
275 ))
276 } else {
277 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
278 }
279 }
280
281 fn compile_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_ref().<'a>(
282 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
283 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
284 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<RefValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/RefValidator#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
285 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(reference)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("$ref") {
286 let resolved = ctx.lookuprust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]lookup().(reference)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
287 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(subschema) = resolved.contentsrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`]contents().() {
288 let validators =
289 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(ctx, subschema).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
290 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(RefValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/RefValidator#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(validators))));
291 }
292 }
293 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
294 }
295
296 fn compile_dynamic_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_dynamic_ref().<'a>(
297 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
298 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
299 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#>>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
300 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(reference)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("$dynamicRef") {
301 let resolved = ctx.lookuprust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]lookup().(reference)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
302 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(subschema) = resolved.contentsrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`]contents().() {
303 let validators =
304 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(ctx, subschema).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
305 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(validators)));
306 }
307 }
308 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
309 }
310
311 fn compile_recursive_refrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_recursive_ref().<'a>(
312 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
313 parent: &Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
314 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PendingItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/PendingItemsValidators#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
315 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parent.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().("$recursiveRef") {
316 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
317 }
318
319 // For $recursiveRef, we need to resolve the reference and check if it's already being compiled
320 let resolved = ctx
321 .lookup_recursive_referencerust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]lookup_recursive_reference().()
322 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::fromrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'_>`][`From<referencing::Error>`]from().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
323
324 // Create context for the resolved reference and check its cache key
325 let (contents, resolver, draft) = resolved.into_innerrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`]into_inner().();
326 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(subschema) = &contents {
327 let vocabularies = ctx.registryrust-analyzer cargo jsonschema 0.37.4 compiler/Context#registry..find_vocabulariesrust-analyzer cargo referencing 0.37.4 registry/impl#[Registry]find_vocabularies().(draft, contents);
328 let ref_ctx =
329 ctx.with_resolver_and_draftrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]with_resolver_and_draft().(resolver, draft, vocabularies, ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().());
330
331 // Check if we're already compiling this schema (circular reference)
332 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pending) = ref_ctx.get_pending_items_validators_for_schemarust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]get_pending_items_validators_for_schema().(subschema) {
333 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pending));
334 }
335
336 let cache_key = ref_ctx.location_cache_keyrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location_cache_key().();
337 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pending) = ref_ctx.get_pending_items_validatorsrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]get_pending_items_validators().(&cache_key) {
338 // Circular reference detected - return the pending node
339 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pending));
340 }
341
342 // Not circular, compile normally
343 let validators =
344 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(&ref_ctx, subschema).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
345 let pending = Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().());
346 let _ = pending.setrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]set().(validators);
347 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pending))
348 } else {
349 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
350 }
351 }
352
353 fn compile_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items().<'a>(
354 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
355 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
356 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, bool), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
357 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(subschema) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("items") {
358 if ctx.draftrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]draft().() rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909#
359 || ctx.draftrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]draft().() rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#
360 || ctx.draftrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]draft().() rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6#
361 || ctx.draftrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]draft().() rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4#
362 {
363 // Older drafts: items can be array or object
364 let limit = if parent.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().("additionalItems") || subschema.is_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]is_object().() {
365 usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX.
366 } else {
367 subschema.as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().().map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX., stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().)
368 };
369 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(limit), false))
370 } else {
371 // Draft 2020-12+: items is always a schema that applies to all items
372 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, true))
373 }
374 } else {
375 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, false))
376 }
377 }
378
379 fn compile_prefix_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_prefix_items().<'a>(
380 _ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
381 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
382 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
383 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(items)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("prefixItems").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().) {
384 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()))
385 } else {
386 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
387 }
388 }
389
390 fn compile_conditionalrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_conditional().<'a>(
391 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
392 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
393 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<ConditionalValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#>>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
394 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(subschema) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("if") {
395 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(if_parent) = subschema {
396 let if_ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("if");
397
398 let mut then_ = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
399 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(subschema)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("then") {
400 let then_ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("then");
401 then_ = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(
402 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(&then_ctx, subschema)
403 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
404 );
405 }
406
407 let mut else_ = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
408 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(subschema)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("else") {
409 let else_ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("else");
410 else_ = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(
411 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(&else_ctx, subschema)
412 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
413 );
414 }
415
416 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ConditionalValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators# {
417 conditionrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#condition.: compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&if_ctx, if_ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(subschema))
418 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
419 if_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#if_.: compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(&if_ctx, if_parent)
420 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
421 then_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#then_.,
422 else_rust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ConditionalValidators#else_.,
423 })));
424 }
425 }
426 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
427 }
428
429 fn compile_all_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_all_of().<'a>(
430 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
431 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
432 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#)>>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
433 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(subschemas)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("allOf").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().) {
434 let all_of_ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("allOf");
435 let mut result = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(subschemas.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().());
436
437 for (idx, subschema) in subschemas.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
438 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(parent) = subschema {
439 let subschema_ctx = all_of_ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(idx);
440 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((
441 compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&subschema_ctx, subschema_ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(subschema))
442 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
443 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(&subschema_ctx, parent)
444 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
445 ));
446 }
447 }
448
449 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(result))
450 } else {
451 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
452 }
453 }
454
455 fn compile_any_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_any_of().<'a>(
456 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
457 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
458 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#)>>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
459 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(subschemas)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("anyOf").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().) {
460 let any_of_ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("anyOf");
461 let mut result = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(subschemas.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().());
462
463 for (idx, subschema) in subschemas.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
464 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(parent) = subschema {
465 let subschema_ctx = any_of_ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(idx);
466 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((
467 compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&subschema_ctx, subschema_ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(subschema))
468 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
469 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(&subschema_ctx, parent)
470 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
471 ));
472 }
473 }
474
475 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(result))
476 } else {
477 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
478 }
479 }
480
481 fn compile_one_ofrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_one_of().<'a>(
482 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>,
483 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
484 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#)>>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'a>> {
485 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(subschemas)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("oneOf").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().) {
486 let one_of_ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("oneOf");
487 let mut result = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(subschemas.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().());
488
489 for (idx, subschema) in subschemas.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
490 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(parent) = subschema {
491 let subschema_ctx = one_of_ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(idx);
492 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((
493 compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&subschema_ctx, subschema_ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(subschema))
494 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
495 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(&subschema_ctx, parent)
496 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
497 ));
498 }
499 }
500
501 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(result))
502 } else {
503 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
504 }
505 }
506
507 /// Validator for the `unevaluatedItems` keyword.
508 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct UnevaluatedItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator# {
509 locationrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
510 validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#validators.: ItemsValidatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#,
511 }
512
513 impl UnevaluatedItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator# {
514 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[UnevaluatedItemsValidator]compile().<'a>(
515 ctx: &'a compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
516 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
517 ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
518 let validators =
519 compile_items_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile_items_validators().(ctx, parent).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
520
521 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(UnevaluatedItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator# {
522 locationrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#location.: ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("unevaluatedItems"),
523 validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#validators.,
524 }))
525 }
526 }
527
528 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for UnevaluatedItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator# {
529 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[UnevaluatedItemsValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool {
530 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
531 let mut indexes = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![false; items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()];
532 self.validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#validators.
533 .mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, &mut indexes, ctx);
534
535 for (item, is_evaluated) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(indexes) {
536 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_evaluated {
537 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(validator) = &self.validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#validators..unevaluatedrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#unevaluated. {
538 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validator.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(item, ctx) {
539 return false;
540 }
541 } else {
542 // unevaluatedItems: false and item not evaluated
543 return false;
544 }
545 }
546 }
547 }
548 true
549 }
550
551 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[UnevaluatedItemsValidator][Validate]validate().<'i>(
552 &self,
553 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
554 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
555 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
556 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
557 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
558 let mut indexes = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![false; items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()];
559 self.validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#validators.
560 .mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, &mut indexes, ctx);
561 let mut unevaluated = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
562
563 for (item, is_evaluated) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(indexes) {
564 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_evaluated {
565 let is_valid = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(validator) = &self.validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#validators..unevaluatedrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#unevaluated. {
566 validator.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(item, ctx)
567 } else {
568 false
569 };
570
571 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid {
572 unevaluated.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(item.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
573 }
574 }
575 }
576
577 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().unevaluated.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
578 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::unevaluated_itemsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]unevaluated_items().(
579 self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
580 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
581 instance,
582 unevaluated,
583 ));
584 }
585 }
586 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
587 }
588
589 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[UnevaluatedItemsValidator][Validate]evaluate().(
590 &self,
591 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
592 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
593 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
594 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
595 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
596 let mut indexes = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![false; items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()];
597 self.validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#validators.
598 .mark_evaluated_indexesrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[ItemsValidators]mark_evaluated_indexes().(instance, &mut indexes, ctx);
599 let mut children = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
600 let mut unevaluated = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
601 let mut invalid = false;
602
603 for (idx, (item, is_evaluated)) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(indexes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()).enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
604 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().is_evaluated {
605 continue;
606 }
607 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(validator) = &self.validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#validators..unevaluatedrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/ItemsValidators#unevaluated. {
608 let child = validator.evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx);
609 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().child.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid. {
610 invalid = true;
611 unevaluated.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(item.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
612 }
613 children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(child);
614 } else {
615 invalid = true;
616 unevaluated.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(item.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
617 }
618 }
619
620 let mut errors = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
621 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().unevaluated.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
622 errors.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_validation_errorrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]from_validation_error().(
623 &ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::unevaluated_itemsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]unevaluated_items().(
624 self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
625 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
626 instance,
627 unevaluated,
628 ),
629 ));
630 }
631
632 if invalid {
633 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Invalidrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid# {
634 errorsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#errors.,
635 childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#children.,
636 annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#annotations.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
637 }
638 } else {
639 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Validrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid# {
640 annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#annotations.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
641 childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#children.,
642 }
643 }
644 } else {
645 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().()
646 }
647 }
648 }
649
650 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/compile().<'a>(
651 ctx: &'a compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
652 parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
653 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
654 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
655 match schema.as_boolrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_bool().() {
656 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
657 _ => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UnevaluatedItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/UnevaluatedItemsValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/impl#[UnevaluatedItemsValidator]compile().(ctx, parent)),
658 }
659 }
660
661 #[cfg(test)]
662 mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/tests/ {
663 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!;
664
665 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
666 fn test_unevaluated_items_with_recursionrust-analyzer cargo jsonschema 0.37.4 keywords/unevaluated_items/tests/test_unevaluated_items_with_recursion().() {
667 let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({
668 "$schema": "https://json-schema.org/draft/2020-12/schema",
669 "allOf": [
670 {
671 "$ref": "#/$defs/array_1"
672 }
673 ],
674 "unevaluatedItems": false,
675 "$defs": {
676 "array_1": {
677 "type": "array",
678 "prefixItems": [
679 {
680 "type": "string"
681 },
682 {
683 "allOf": [
684 {
685 "$ref": "#/$defs/array_2"
686 }
687 ],
688 "type": "array",
689 "unevaluatedItems": false
690 }
691 ]
692 },
693 "array_2": {
694 "type": "array",
695 "prefixItems": [
696 {
697 "type": "number"
698 },
699 {
700 "allOf": [
701 {
702 "$ref": "#/$defs/array_1"
703 }
704 ],
705 "type": "array",
706 "unevaluatedItems": false
707 }
708 ]
709 }
710 }
711 });
712
713 let validator = craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Schema should compile");
714
715 // This instance should fail validation because the nested array has an unevaluated item
716 let instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([
717 "string",
718 [
719 42,
720 [
721 "string",
722 [
723 42,
724 "unexpected" // This item should cause validation to fail
725 ]
726 ]
727 ]
728 ]);
729
730 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&instance));
731 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validator.validaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]validate().(&instance).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
732
733 // This instance should pass validation as all items are evaluated
734 let valid_instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(["string", [42, ["string", [42]]]]);
735
736 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&valid_instance));
737 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validator.validaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]validate().(&valid_instance).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
738 }
739 }