Debian Codegraph @

src/keywords/property_names.rs

raw symbols SCIP
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 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 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#},
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 PropertyNamesObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator# {
12 noderust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
13 }
14
15 impl PropertyNamesObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator# {
16 #[inline]
17 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesObjectValidator]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> {
18 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("propertyNames");
19 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().(PropertyNamesObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator# {
20 noderust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator#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().,
21 }))
22 }
23 }
24
25 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for PropertyNamesObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator# {
26 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesObjectValidator][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 {
27 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 {
28 item.keysrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]keys().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(move |key| {
29 let wrapper = Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(key.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().());
30 self.noderust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator#node..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(&wrapper, ctx)
31 })
32 } else {
33 true
34 }
35 }
36
37 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesObjectValidator][Validate]validate().<'i>(
38 &self,
39 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
40 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
41 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
42 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
43 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 {
44 for key in item.keysrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]keys().() {
45 let wrapper = Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(key.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().());
46 match self.noderust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator#node..validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(&wrapper, location, ctx) {
47 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) => {}
48 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => {
49 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#::property_namesrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]property_names().(
50 error.schema_pathrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]schema_path().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
51 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
52 instance,
53 error.to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().(),
54 ))
55 }
56 }
57 }
58 }
59 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
60 }
61
62 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesObjectValidator][Validate]iter_errors().<'i>(
63 &self,
64 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
65 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
66 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
67 ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> {
68 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 {
69 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().();
70 for key in item.keysrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]keys().() {
71 let wrapper = Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(key.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().());
72 errors.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(self.noderust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator#node..iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(&wrapper, location, ctx).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|error| {
73 ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::property_namesrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]property_names().(
74 error.schema_pathrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]schema_path().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
75 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
76 instance,
77 error.to_ownedrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]to_owned().(),
78 )
79 }));
80 }
81 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().())
82 } else {
83 no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().()
84 }
85 }
86
87 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesObjectValidator][Validate]evaluate().(
88 &self,
89 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
90 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
91 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
92 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
93 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 {
94 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().(item.lenrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]len().());
95 for key in item.keysrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]keys().() {
96 let wrapper = Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(key.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().());
97 children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(self.noderust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator#node..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(&wrapper, location, ctx));
98 }
99 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children)
100 } else {
101 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().()
102 }
103 }
104 }
105
106 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct PropertyNamesBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesBooleanValidator# {
107 locationrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesBooleanValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
108 }
109
110 impl PropertyNamesBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesBooleanValidator# {
111 #[inline]
112 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesBooleanValidator]compile().<'a>(ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
113 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().("propertyNames");
114 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().(PropertyNamesBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesBooleanValidator# { locationrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesBooleanValidator#location. }))
115 }
116 }
117
118 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for PropertyNamesBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesBooleanValidator# {
119 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesBooleanValidator][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 {
120 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 {
121 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().item.is_emptyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]is_empty().() {
122 return false;
123 }
124 }
125 true
126 }
127
128 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesBooleanValidator][Validate]validate().<'i>(
129 &self,
130 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
131 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
132 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
133 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
134 if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesBooleanValidator][Validate]is_valid().(instance, ctx) {
135 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
136 } else {
137 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::false_schemarust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]false_schema().(
138 self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesBooleanValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
139 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
140 instance,
141 ))
142 }
143 }
144 }
145
146 #[inline]
147 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/property_names/compile().<'a>(
148 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
149 _: &'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#>,
150 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
151 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
152 match schema {
153 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(_) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PropertyNamesObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesObjectValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesObjectValidator]compile().(ctx, schema)),
154 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Boolrust-analyzer cargo serde_json 1.0.145 value/Value#Bool#(false) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PropertyNamesBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/PropertyNamesBooleanValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/property_names/impl#[PropertyNamesBooleanValidator]compile().(ctx)),
155 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
156 }
157 }
158
159 #[cfg(test)]
160 mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/tests/ {
161 use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/;
162 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#};
163 use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:;
164
165 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"propertyNames": false}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"foo": 1}), "/propertyNames")]
166 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"propertyNames": {"minLength": 2}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"f": 1}), "/propertyNames/minLength")]
167 fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/property_names/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) {
168 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);
169 }
170 }