| 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/::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#, ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#}, |
| 5 | keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#, |
| 6 | noderust-analyzer cargo jsonschema 0.37.4 node/::SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 7 | pathsrust-analyzer cargo jsonschema 0.37.4 paths/::LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 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 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#, |
| 10 | }; |
| 11 | 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#}; |
| 12 | |
| 13 | use superrust-analyzer cargo jsonschema 0.37.4 keywords/::helpersrust-analyzer cargo jsonschema 0.37.4 keywords/helpers/::map_get_u64rust-analyzer cargo jsonschema 0.37.4 keywords/helpers/map_get_u64().; |
| 14 | |
| 15 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct ContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator# { |
| 16 | noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 17 | } |
| 18 | |
| 19 | impl ContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator# { |
| 20 | #[inline] |
| 21 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[ContainsValidator]compile().<'a>(ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 22 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("contains"); |
| 23 | 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().(ContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator# { |
| 24 | noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#node.: 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().(schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 25 | })) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator# { |
| 30 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[ContainsValidator][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 { |
| 31 | 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 { |
| 32 | items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|i| self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#node..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(i, ctx)) |
| 33 | } else { |
| 34 | true |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[ContainsValidator][Validate]validate().<'i>( |
| 39 | &self, |
| 40 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 41 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 42 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 43 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 44 | 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 { |
| 45 | if items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|i| self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#node..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(i, ctx)) { |
| 46 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 47 | } |
| 48 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::containsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]contains().( |
| 49 | self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#node..locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 50 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 51 | instance, |
| 52 | )) |
| 53 | } else { |
| 54 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[ContainsValidator][Validate]evaluate().( |
| 59 | &self, |
| 60 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 61 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 62 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 63 | ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# { |
| 64 | 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 { |
| 65 | let mut results = 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 alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 66 | let mut indices = 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 alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 67 | 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().() { |
| 68 | let path = location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx); |
| 69 | let result = self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#node..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(item, &path, ctx); |
| 70 | if result.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid. { |
| 71 | indices.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(idx); |
| 72 | results.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(result); |
| 73 | } |
| 74 | } |
| 75 | if indices.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 76 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Invalidrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid# { |
| 77 | errorsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#errors.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_validation_errorrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]from_validation_error().( |
| 78 | &ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::containsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]contains().( |
| 79 | self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#node..locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 80 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 81 | instance, |
| 82 | ), |
| 83 | )], |
| 84 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#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().(), |
| 85 | 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#, |
| 86 | } |
| 87 | } else { |
| 88 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Validrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid# { |
| 89 | annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#annotations.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]new().(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::fromrust-analyzer cargo serde_json 1.0.145 value/from/impl#[Value][`From<Vec<T>>`]from().(indices))), |
| 90 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#children.: results, |
| 91 | } |
| 92 | } |
| 93 | } else { |
| 94 | let mut result = EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().(); |
| 95 | 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().(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(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().()))); |
| 96 | result |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /// `minContains` validation. Used only if there is no `maxContains` present. |
| 102 | /// |
| 103 | /// Docs: <https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4.5> |
| 104 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct MinContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator# { |
| 105 | noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 106 | min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#min_contains.: u64, |
| 107 | } |
| 108 | |
| 109 | impl MinContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator# { |
| 110 | #[inline] |
| 111 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MinContainsValidator]compile().<'a>( |
| 112 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 113 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 114 | min_contains: u64, |
| 115 | ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 116 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("minContains"); |
| 117 | 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().(MinContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator# { |
| 118 | noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#node.: 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().(schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 119 | min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#min_contains., |
| 120 | })) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for MinContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator# { |
| 125 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MinContainsValidator][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 { |
| 126 | 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 { |
| 127 | let mut matches = 0; |
| 128 | for item in items { |
| 129 | if self |
| 130 | .noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#node. |
| 131 | .validatorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]validators().() |
| 132 | .allrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]all().(|validator| validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(item, ctx)) |
| 133 | { |
| 134 | matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().1; |
| 135 | if matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().self.min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#min_contains. { |
| 136 | return true; |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | self.min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#min_contains. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().0 |
| 141 | } else { |
| 142 | true |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MinContainsValidator][Validate]validate().<'i>( |
| 147 | &self, |
| 148 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 149 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 150 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 151 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 152 | 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 { |
| 153 | let mut matches = 0; |
| 154 | for item in items { |
| 155 | if self |
| 156 | .noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#node. |
| 157 | .validatorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]validators().() |
| 158 | .allrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]all().(|validator| validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(item, ctx)) |
| 159 | { |
| 160 | matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().1; |
| 161 | if matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().self.min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#min_contains. { |
| 162 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | if self.min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#min_contains. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 { |
| 167 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::containsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]contains().( |
| 168 | self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#node..locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 169 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 170 | instance, |
| 171 | )) |
| 172 | } else { |
| 173 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 174 | } |
| 175 | } else { |
| 176 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | /// `maxContains` validation. Used only if there is no `minContains` present. |
| 182 | /// |
| 183 | /// Docs: <https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4.4> |
| 184 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct MaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator# { |
| 185 | noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 186 | max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#max_contains.: u64, |
| 187 | } |
| 188 | |
| 189 | impl MaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator# { |
| 190 | #[inline] |
| 191 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MaxContainsValidator]compile().<'a>( |
| 192 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 193 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 194 | max_contains: u64, |
| 195 | ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 196 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("maxContains"); |
| 197 | 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().(MaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator# { |
| 198 | noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#node.: 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().(schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 199 | max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#max_contains., |
| 200 | })) |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for MaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator# { |
| 205 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MaxContainsValidator][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 { |
| 206 | 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 { |
| 207 | let mut matches = 0; |
| 208 | for item in items { |
| 209 | if self |
| 210 | .noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#node. |
| 211 | .validatorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]validators().() |
| 212 | .allrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]all().(|validator| validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(item, ctx)) |
| 213 | { |
| 214 | matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().1; |
| 215 | if matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().self.max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#max_contains. { |
| 216 | return false; |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 |
| 221 | } else { |
| 222 | true |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MaxContainsValidator][Validate]validate().<'i>( |
| 227 | &self, |
| 228 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 229 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 230 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 231 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 232 | 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 { |
| 233 | let mut matches = 0; |
| 234 | for item in items { |
| 235 | if self |
| 236 | .noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#node. |
| 237 | .validatorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]validators().() |
| 238 | .allrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]all().(|validator| validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(item, ctx)) |
| 239 | { |
| 240 | matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().1; |
| 241 | if matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().self.max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#max_contains. { |
| 242 | 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#::containsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]contains().( |
| 243 | self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#node..locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 244 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 245 | instance, |
| 246 | )); |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | if matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 { |
| 251 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 252 | } else { |
| 253 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::containsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]contains().( |
| 254 | self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#node..locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 255 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 256 | instance, |
| 257 | )) |
| 258 | } |
| 259 | } else { |
| 260 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | /// `maxContains` & `minContains` validation combined. |
| 266 | /// |
| 267 | /// Docs: |
| 268 | /// `maxContains` - <https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4.4> |
| 269 | /// `minContains` - <https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4.5> |
| 270 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct MinMaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator# { |
| 271 | noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 272 | min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#min_contains.: u64, |
| 273 | max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#max_contains.: u64, |
| 274 | } |
| 275 | |
| 276 | impl MinMaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator# { |
| 277 | #[inline] |
| 278 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MinMaxContainsValidator]compile().<'a>( |
| 279 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 280 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 281 | min_contains: u64, |
| 282 | max_contains: u64, |
| 283 | ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 284 | 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().(MinMaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator# { |
| 285 | noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#node.: 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().(schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 286 | min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#min_contains., |
| 287 | max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#max_contains., |
| 288 | })) |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for MinMaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator# { |
| 293 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MinMaxContainsValidator][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 { |
| 294 | 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 { |
| 295 | let mut matches = 0; |
| 296 | for item in items { |
| 297 | if self |
| 298 | .noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#node. |
| 299 | .validatorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]validators().() |
| 300 | .allrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]all().(|validator| validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(item, ctx)) |
| 301 | { |
| 302 | matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().1; |
| 303 | if matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().self.max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#max_contains. { |
| 304 | return false; |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]le().self.max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#max_contains. && matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().self.min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#min_contains. |
| 309 | } else { |
| 310 | true |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MinMaxContainsValidator][Validate]validate().<'i>( |
| 315 | &self, |
| 316 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 317 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 318 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 319 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 320 | 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 { |
| 321 | let mut matches = 0; |
| 322 | for item in items { |
| 323 | if self |
| 324 | .noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#node. |
| 325 | .validatorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]validators().() |
| 326 | .allrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]all().(|validator| validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(item, ctx)) |
| 327 | { |
| 328 | matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().1; |
| 329 | if matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().self.max_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#max_contains. { |
| 330 | 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#::containsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]contains().( |
| 331 | self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#node..locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("maxContains"), |
| 332 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 333 | instance, |
| 334 | )); |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | if matches rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]lt().self.min_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#min_contains. { |
| 339 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::containsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]contains().( |
| 340 | self.noderust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#node..locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("minContains"), |
| 341 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 342 | instance, |
| 343 | )) |
| 344 | } else { |
| 345 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 346 | } |
| 347 | } else { |
| 348 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | #[inline] |
| 354 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/compile().<'a>( |
| 355 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 356 | 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#>, |
| 357 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 358 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 359 | match ctx.draftrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]draft().() { |
| 360 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => { |
| 361 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[ContainsValidator]compile().(ctx, schema)) |
| 362 | } |
| 363 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012# => compile_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/compile_contains().(ctx, parent, schema), |
| 364 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | #[inline] |
| 369 | fn compile_containsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/compile_contains().<'a>( |
| 370 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 371 | 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#>, |
| 372 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 373 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 374 | let min_contains = match map_get_u64rust-analyzer cargo jsonschema 0.37.4 keywords/helpers/map_get_u64().(parent, ctx, "minContains").transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().() { |
| 375 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n) => n, |
| 376 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => return 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#(err)), |
| 377 | }; |
| 378 | let max_contains = match map_get_u64rust-analyzer cargo jsonschema 0.37.4 keywords/helpers/map_get_u64().(parent, ctx, "maxContains").transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().() { |
| 379 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n) => n, |
| 380 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => return 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#(err)), |
| 381 | }; |
| 382 | |
| 383 | match (min_contains, max_contains) { |
| 384 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(min), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(max)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MinMaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinMaxContainsValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MinMaxContainsValidator]compile().(ctx, schema, min, max)), |
| 385 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(min), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MinContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MinContainsValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MinContainsValidator]compile().(ctx, schema, min)), |
| 386 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(max)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MaxContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/MaxContainsValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[MaxContainsValidator]compile().(ctx, schema, max)), |
| 387 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ContainsValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/contains/ContainsValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/contains/impl#[ContainsValidator]compile().(ctx, schema)), |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | #[cfg(test)] |
| 392 | mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/contains/tests/ { |
| 393 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/; |
| 394 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!; |
| 395 | |
| 396 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 397 | fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/contains/tests/location().() { |
| 398 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::assert_schema_locationrust-analyzer cargo jsonschema 0.37.4 tests_util/assert_schema_location().( |
| 399 | &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"contains": {"const": 2}}), |
| 400 | &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([]), |
| 401 | "/contains", |
| 402 | ); |
| 403 | } |
| 404 | } |