| 171 | } |
| 172 | |
| 173 | fn validate_status(status: &RequestStatus) -> ModelValidatorResult<RequestError> { |
| 174 | match status { |
| 175 | RequestStatus::Cancelled { |
| 176 | reason: Some(reason), |
| 177 | } => { |
| 178 | if reason.trim().is_empty() { |
| 179 | return Err(RequestError::ValidationError { |
| 180 | info: "The reason for the cancellation must not be empty".to_owned(), |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | if reason.len() > Request::MAX_CANCEL_REASON_LEN as usize { |
| 185 | return Err(RequestError::ValidationError { |
| 186 | info: format!( |
| 187 | "The reason for the cancellation exceeds the maximum allowed: {}", |
| 188 | Request::MAX_CANCEL_REASON_LEN |
| 189 | ), |
| 190 | }); |
| 191 | } |
| 192 | |
| 193 | Ok(()) |
| 194 | } |
| 195 | RequestStatus::Created |
| 196 | | RequestStatus::Rejected |
| 197 | | RequestStatus::Approved |
| 198 | | RequestStatus::Completed { .. } |
| 199 | | RequestStatus::Failed { .. } |
| 200 | | RequestStatus::Scheduled { .. } |
| 201 | | RequestStatus::Processing { .. } |
| 202 | | RequestStatus::Cancelled { reason: None } => Ok(()), |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | fn validate_execution_plan( |
| 207 | execution_plan: &RequestExecutionPlan, |