MCPcopy Create free account
hub / github.com/cedar-policy/cedar-java / validate_with_level

Function validate_with_level

CedarJavaFFI/src/helpers.rs:145–184  ·  view source on GitHub ↗
(call: LevelValidationCall)

Source from the content-addressed store, hash-verified

143}
144
145pub fn validate_with_level(call: LevelValidationCall) -> ValidationAnswer {
146 match call.get_components() {
147 WithWarnings {
148 t: Ok((policies, schema, settings, max_deref_level)),
149 warnings,
150 } => {
151 let validator = Validator::new(schema);
152
153 let validation_result =
154 validator.validate_with_level(&policies, settings.mode, max_deref_level);
155 let validation_errors = validation_result.validation_errors();
156 let validation_warnings = validation_result.validation_warnings();
157
158 let validation_errors: Vec<ValidationError> = validation_errors
159 .map(|error| ValidationError {
160 policy_id: error.policy_id().clone(),
161 error: miette::Report::new(error.clone()).into(),
162 })
163 .collect();
164 let validation_warnings: Vec<ValidationError> = validation_warnings
165 .map(|error| ValidationError {
166 policy_id: error.policy_id().clone(),
167 error: miette::Report::new(error.clone()).into(),
168 })
169 .collect();
170 ValidationAnswer::Success {
171 validation_errors,
172 validation_warnings,
173 other_warnings: warnings.into_iter().map(Into::into).collect(),
174 }
175 }
176 WithWarnings {
177 t: Err(errors),
178 warnings,
179 } => ValidationAnswer::Failure {
180 errors: errors.into_iter().map(Into::into).collect(),
181 warnings: warnings.into_iter().map(Into::into).collect(),
182 },
183 }
184}
185
186#[cfg(test)]
187mod test {

Calls 1

get_componentsMethod · 0.80

Tested by

no test coverage detected