(
self,
)
| 101 | |
| 102 | impl LevelValidationCall { |
| 103 | fn get_components( |
| 104 | self, |
| 105 | ) -> WithWarnings<Result<(PolicySet, Schema, ValidationSettings, u32), Vec<miette::Report>>> |
| 106 | { |
| 107 | let mut errs = vec![]; |
| 108 | let policies = match self.policies.parse() { |
| 109 | Ok(policies) => policies, |
| 110 | Err(e) => { |
| 111 | errs.extend(e); |
| 112 | PolicySet::new() |
| 113 | } |
| 114 | }; |
| 115 | let pair = match self.schema.parse() { |
| 116 | Ok((schema, warnings)) => Some((schema, warnings)), |
| 117 | Err(e) => { |
| 118 | errs.push(e); |
| 119 | None |
| 120 | } |
| 121 | }; |
| 122 | match (errs.is_empty(), pair) { |
| 123 | (true, Some((schema, warnings))) => WithWarnings { |
| 124 | t: Ok(( |
| 125 | policies, |
| 126 | schema, |
| 127 | self.validation_settings, |
| 128 | self.max_deref_level, |
| 129 | )), |
| 130 | warnings: warnings.map(miette::Report::new).collect(), |
| 131 | }, |
| 132 | _ => WithWarnings { |
| 133 | t: Err(errs), |
| 134 | warnings: vec![], |
| 135 | }, |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | pub fn validate_with_level_json_str(json: &str) -> Result<String, serde_json::Error> { |
no test coverage detected