MCPcopy Create free account
hub / github.com/dfinity/orbit / validate_status

Function validate_status

core/station/impl/src/models/request.rs:173–204  ·  view source on GitHub ↗
(status: &RequestStatus)

Source from the content-addressed store, hash-verified

171}
172
173fn 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
206fn validate_execution_plan(
207 execution_plan: &RequestExecutionPlan,

Calls 2

is_emptyMethod · 0.45
lenMethod · 0.45