| 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 | keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#, |
| 5 | 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#}, |
| 6 | typesrust-analyzer cargo jsonschema 0.37.4 types/::JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#, |
| 7 | validatorrust-analyzer cargo jsonschema 0.37.4 validator/::{Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#, ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#}, |
| 8 | }; |
| 9 | 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#}; |
| 10 | |
| 11 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct RequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator# { |
| 12 | requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#required.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 13 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 14 | } |
| 15 | |
| 16 | impl RequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator# { |
| 17 | #[inline] |
| 18 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[RequiredValidator]compile().(items: &[Valuerust-analyzer cargo serde_json 1.0.145 value/Value#], location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'_> { |
| 19 | let mut required = 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().()); |
| 20 | for item in items { |
| 21 | match item { |
| 22 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(string) => required.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(string.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()), |
| 23 | _ => { |
| 24 | 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#::single_type_errorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]single_type_error().( |
| 25 | Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(), |
| 26 | location, |
| 27 | item, |
| 28 | JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Stringrust-analyzer cargo jsonschema 0.37.4 types/JsonType#String#, |
| 29 | )) |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | 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().(RequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator# { requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#required., locationrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#location. })) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for RequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator# { |
| 38 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[RequiredValidator][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 { |
| 39 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance { |
| 40 | if item.lenrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#required..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() { |
| 41 | return false; |
| 42 | } |
| 43 | self.requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#required. |
| 44 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 45 | .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|property_name| item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property_name)) |
| 46 | } else { |
| 47 | true |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[RequiredValidator][Validate]validate().<'i>( |
| 52 | &self, |
| 53 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 54 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 55 | _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 56 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 57 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance { |
| 58 | for property_name in &self.requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#required. { |
| 59 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property_name) { |
| 60 | 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#::requiredrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]required().( |
| 61 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 62 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 63 | instance, |
| 64 | // Value enum is needed for proper string escaping |
| 65 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(property_name.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()), |
| 66 | )); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 71 | } |
| 72 | fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[RequiredValidator][Validate]iter_errors().<'i>( |
| 73 | &self, |
| 74 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 75 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 76 | _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 77 | ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> { |
| 78 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance { |
| 79 | let mut errors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 80 | for property_name in &self.requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#required. { |
| 81 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property_name) { |
| 82 | errors.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::requiredrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]required().( |
| 83 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 84 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 85 | instance, |
| 86 | // Value enum is needed for proper string escaping |
| 87 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(property_name.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()), |
| 88 | )); |
| 89 | } |
| 90 | } |
| 91 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().errors.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 92 | return 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().()); |
| 93 | } |
| 94 | } |
| 95 | no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().() |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct SingleItemRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator# { |
| 100 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator#value.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 101 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 102 | } |
| 103 | |
| 104 | impl SingleItemRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator# { |
| 105 | #[inline] |
| 106 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[SingleItemRequiredValidator]compile().(value: &str, location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'_> { |
| 107 | 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().(SingleItemRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator# { |
| 108 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator#value.: value.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 109 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator#location., |
| 110 | })) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for SingleItemRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator# { |
| 115 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[SingleItemRequiredValidator][Validate]validate().<'i>( |
| 116 | &self, |
| 117 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 118 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 119 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 120 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 121 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[SingleItemRequiredValidator][Validate]is_valid().(instance, ctx) { |
| 122 | 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#::requiredrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]required().( |
| 123 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 124 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 125 | instance, |
| 126 | // Value enum is needed for proper string escaping |
| 127 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator#value..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()), |
| 128 | )); |
| 129 | } |
| 130 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 131 | } |
| 132 | |
| 133 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[SingleItemRequiredValidator][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 { |
| 134 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance { |
| 135 | if item.is_emptyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]is_empty().() { |
| 136 | return false; |
| 137 | } |
| 138 | item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(&self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator#value.) |
| 139 | } else { |
| 140 | true |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | #[inline] |
| 146 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/required/compile().<'a>( |
| 147 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 148 | _: &'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#>, |
| 149 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 150 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 151 | let 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().("required"); |
| 152 | compile_with_pathrust-analyzer cargo jsonschema 0.37.4 keywords/required/compile_with_path().(schema, location) |
| 153 | } |
| 154 | |
| 155 | #[inline] |
| 156 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compile_with_pathrust-analyzer cargo jsonschema 0.37.4 keywords/required/compile_with_path().( |
| 157 | schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 158 | location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 159 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'_>> { |
| 160 | // IMPORTANT: If this function will ever return `None`, adjust `dependencies.rs` accordingly |
| 161 | match schema { |
| 162 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) => { |
| 163 | if items.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().1 { |
| 164 | let item = &items[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 165 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(item) = item { |
| 166 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(SingleItemRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/SingleItemRequiredValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[SingleItemRequiredValidator]compile().(item, location)) |
| 167 | } else { |
| 168 | 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().( |
| 169 | Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(), |
| 170 | location, |
| 171 | item, |
| 172 | JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Stringrust-analyzer cargo jsonschema 0.37.4 types/JsonType#String#, |
| 173 | ))) |
| 174 | } |
| 175 | } else { |
| 176 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(RequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/required/RequiredValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/required/impl#[RequiredValidator]compile().(items, location)) |
| 177 | } |
| 178 | } |
| 179 | _ => 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().( |
| 180 | Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(), |
| 181 | location, |
| 182 | schema, |
| 183 | JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Arrayrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Array#, |
| 184 | ))), |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | #[cfg(test)] |
| 189 | mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/required/tests/ { |
| 190 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/; |
| 191 | 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#}; |
| 192 | use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 193 | |
| 194 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"required": ["a"]}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({}), "/required")] |
| 195 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"required": ["a", "b"]}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({}), "/required")] |
| 196 | fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/required/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) { |
| 197 | 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); |
| 198 | } |
| 199 | } |