| 1 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::{ |
| 2 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/, |
| 3 | errorrust-analyzer cargo jsonschema 0.37.4 error/::{no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error()., ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#}, |
| 4 | evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/::Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#, |
| 5 | noderust-analyzer cargo jsonschema 0.37.4 node/::SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 6 | 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#}, |
| 7 | typesrust-analyzer cargo jsonschema 0.37.4 types/::JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#, |
| 8 | 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#}, |
| 9 | }; |
| 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 | |
| 12 | use superrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#; |
| 13 | |
| 14 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct PrefixItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator# { |
| 15 | schemasrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator#schemas.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#>, |
| 16 | } |
| 17 | |
| 18 | impl PrefixItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator# { |
| 19 | #[inline] |
| 20 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/impl#[PrefixItemsValidator]compile().<'a>( |
| 21 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 22 | items: &'a [Valuerust-analyzer cargo serde_json 1.0.145 value/Value#], |
| 23 | ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 24 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("prefixItems"); |
| 25 | let mut schemas = 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().(items.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 26 | for (idx, item) in items.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().() { |
| 27 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(idx); |
| 28 | let validators = compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(item))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 29 | schemas.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(validators); |
| 30 | } |
| 31 | 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().(PrefixItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator# { schemasrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator#schemas. })) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for PrefixItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator# { |
| 36 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/impl#[PrefixItemsValidator][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 { |
| 37 | 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 { |
| 38 | for (schema, item) in self.schemasrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator#schemas..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().(items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) { |
| 39 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().schema.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(item, ctx) { |
| 40 | return false; |
| 41 | } |
| 42 | } |
| 43 | true |
| 44 | } else { |
| 45 | true |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/impl#[PrefixItemsValidator][Validate]validate().<'i>( |
| 50 | &self, |
| 51 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 52 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 53 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 54 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 55 | 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 { |
| 56 | for (idx, (schema, item)) in self.schemasrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator#schemas..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().(items.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().() { |
| 57 | schema.validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 58 | } |
| 59 | } |
| 60 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 61 | } |
| 62 | |
| 63 | fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/impl#[PrefixItemsValidator][Validate]iter_errors().<'i>( |
| 64 | &self, |
| 65 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 66 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 67 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 68 | ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> { |
| 69 | 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 { |
| 70 | 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().(); |
| 71 | for (idx, (schema, item)) in self.schemasrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator#schemas..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().(items.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().() { |
| 72 | errors.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(schema.iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx)); |
| 73 | } |
| 74 | ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#::from_iteratorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ErrorIterator<'a>`]from_iterator().(errors.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()) |
| 75 | } else { |
| 76 | no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().() |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/impl#[PrefixItemsValidator][Validate]evaluate().( |
| 81 | &self, |
| 82 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 83 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 84 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 85 | ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# { |
| 86 | 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 { |
| 87 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().items.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 88 | let mut children = 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().(self.schemasrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator#schemas..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().())); |
| 89 | let mut max_index_applied = 0usize; |
| 90 | for (idx, (schema_node, item)) in self.schemasrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator#schemas..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().(items.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().() |
| 91 | { |
| 92 | children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(schema_node.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)); |
| 93 | max_index_applied = idx; |
| 94 | } |
| 95 | let annotation = if children.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() 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().items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() { |
| 96 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Boolrust-analyzer cargo serde_json 1.0.145 value/Value#Bool#(true) |
| 97 | } else { |
| 98 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::fromrust-analyzer cargo serde_json 1.0.145 value/from/impl#[Value][`From<usize>`]from().(max_index_applied) |
| 99 | }; |
| 100 | let mut result = EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children); |
| 101 | result.annotaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]annotate().(Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]new().(annotation)); |
| 102 | return result; |
| 103 | } |
| 104 | } |
| 105 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().() |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | #[inline] |
| 110 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/compile().<'a>( |
| 111 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 112 | _: &'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#>, |
| 113 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 114 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 115 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = schema { |
| 116 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PrefixItemsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/PrefixItemsValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/impl#[PrefixItemsValidator]compile().(ctx, items)) |
| 117 | } else { |
| 118 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::single_type_errorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]single_type_error().( |
| 119 | Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(), |
| 120 | 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().(), |
| 121 | schema, |
| 122 | JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Arrayrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Array#, |
| 123 | ))) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | #[cfg(test)] |
| 128 | mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/tests/ { |
| 129 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/; |
| 130 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{jsonrust-analyzer cargo serde_json 1.0.145 macros/json!, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#}; |
| 131 | use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 132 | |
| 133 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft/2020-12/schema", "prefixItems": [{"type": "integer"}, {"maximum": 5}]}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(["string"]), "/prefixItems/0/type")] |
| 134 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft/2020-12/schema", "prefixItems": [{"type": "integer"}, {"maximum": 5}]}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([42, 42]), "/prefixItems/1/maximum")] |
| 135 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft/2020-12/schema", "prefixItems": [{"type": "integer"}, {"maximum": 5}], "items": {"type": "boolean"}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([42, 1, 42]), "/items/type")] |
| 136 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft/2020-12/schema", "prefixItems": [{"type": "integer"}, {"maximum": 5}], "items": {"type": "boolean"}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([42, 42, true]), "/prefixItems/1/maximum")] |
| 137 | fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/tests/location().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, expected: &str) { |
| 138 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::assert_schema_locationrust-analyzer cargo jsonschema 0.37.4 tests_util/assert_schema_location().(schema, instance, expected); |
| 139 | } |
| 140 | |
| 141 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 142 | fn evaluation_outputs_cover_prefix_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/prefix_items/tests/evaluation_outputs_cover_prefix_items().() { |
| 143 | let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 144 | "type": "object", |
| 145 | "properties": {"name": {"type": "string"}, "age": {"type": "number", "minimum": 0}}, |
| 146 | "required": ["name"] |
| 147 | }); |
| 148 | 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 compiles"); |
| 149 | let evaluation = validator.evaluaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]evaluate().(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"name": "Alice", "age": 1})); |
| 150 | |
| 151 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 152 | serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(evaluation.listrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]list().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 153 | jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 154 | "valid": true, |
| 155 | "details": [ |
| 156 | {"evaluationPath": "", "instanceLocation": "", "schemaLocation": "", "valid": true}, |
| 157 | { |
| 158 | "valid": true, |
| 159 | "evaluationPath": "/properties", |
| 160 | "instanceLocation": "", |
| 161 | "schemaLocation": "/properties", |
| 162 | "annotations": ["age", "name"] |
| 163 | }, |
| 164 | { |
| 165 | "valid": true, |
| 166 | "evaluationPath": "/properties/age", |
| 167 | "instanceLocation": "/age", |
| 168 | "schemaLocation": "/properties/age" |
| 169 | }, |
| 170 | { |
| 171 | "valid": true, |
| 172 | "evaluationPath": "/properties/age/minimum", |
| 173 | "instanceLocation": "/age", |
| 174 | "schemaLocation": "/properties/age/minimum" |
| 175 | }, |
| 176 | { |
| 177 | "valid": true, |
| 178 | "evaluationPath": "/properties/age/type", |
| 179 | "instanceLocation": "/age", |
| 180 | "schemaLocation": "/properties/age/type" |
| 181 | }, |
| 182 | { |
| 183 | "valid": true, |
| 184 | "evaluationPath": "/properties/name", |
| 185 | "instanceLocation": "/name", |
| 186 | "schemaLocation": "/properties/name" |
| 187 | }, |
| 188 | { |
| 189 | "valid": true, |
| 190 | "evaluationPath": "/properties/name/type", |
| 191 | "instanceLocation": "/name", |
| 192 | "schemaLocation": "/properties/name/type" |
| 193 | }, |
| 194 | { |
| 195 | "valid": true, |
| 196 | "evaluationPath": "/required", |
| 197 | "instanceLocation": "", |
| 198 | "schemaLocation": "/required" |
| 199 | }, |
| 200 | { |
| 201 | "valid": true, |
| 202 | "evaluationPath": "/type", |
| 203 | "instanceLocation": "", |
| 204 | "schemaLocation": "/type" |
| 205 | } |
| 206 | ] |
| 207 | }) |
| 208 | ); |
| 209 | |
| 210 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 211 | serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(evaluation.hierarchicalrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]hierarchical().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 212 | jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 213 | "valid": true, |
| 214 | "evaluationPath": "", |
| 215 | "instanceLocation": "", |
| 216 | "schemaLocation": "", |
| 217 | "details": [ |
| 218 | { |
| 219 | "valid": true, |
| 220 | "evaluationPath": "/properties", |
| 221 | "instanceLocation": "", |
| 222 | "schemaLocation": "/properties", |
| 223 | "annotations": ["age", "name"], |
| 224 | "details": [ |
| 225 | { |
| 226 | "valid": true, |
| 227 | "evaluationPath": "/properties/age", |
| 228 | "instanceLocation": "/age", |
| 229 | "schemaLocation": "/properties/age", |
| 230 | "details": [ |
| 231 | { |
| 232 | "valid": true, |
| 233 | "evaluationPath": "/properties/age/minimum", |
| 234 | "instanceLocation": "/age", |
| 235 | "schemaLocation": "/properties/age/minimum" |
| 236 | }, |
| 237 | { |
| 238 | "valid": true, |
| 239 | "evaluationPath": "/properties/age/type", |
| 240 | "instanceLocation": "/age", |
| 241 | "schemaLocation": "/properties/age/type" |
| 242 | } |
| 243 | ] |
| 244 | }, |
| 245 | { |
| 246 | "valid": true, |
| 247 | "evaluationPath": "/properties/name", |
| 248 | "instanceLocation": "/name", |
| 249 | "schemaLocation": "/properties/name", |
| 250 | "details": [ |
| 251 | { |
| 252 | "valid": true, |
| 253 | "evaluationPath": "/properties/name/type", |
| 254 | "instanceLocation": "/name", |
| 255 | "schemaLocation": "/properties/name/type" |
| 256 | } |
| 257 | ] |
| 258 | } |
| 259 | ] |
| 260 | }, |
| 261 | { |
| 262 | "valid": true, |
| 263 | "evaluationPath": "/required", |
| 264 | "instanceLocation": "", |
| 265 | "schemaLocation": "/required" |
| 266 | }, |
| 267 | { |
| 268 | "valid": true, |
| 269 | "evaluationPath": "/type", |
| 270 | "instanceLocation": "", |
| 271 | "schemaLocation": "/type" |
| 272 | } |
| 273 | ] |
| 274 | }) |
| 275 | ); |
| 276 | } |
| 277 | } |