(&self, mutation: &Mutation)
| 354 | } |
| 355 | |
| 356 | fn validate(&self, mutation: &Mutation) -> Result<()> { |
| 357 | if self.parent_topic_ids.is_empty() { |
| 358 | return Err(Error::Repo( |
| 359 | "at least one parent topic must be provided".into(), |
| 360 | )); |
| 361 | } |
| 362 | |
| 363 | for parent in self.parent_topic_ids.iter() { |
| 364 | if mutation.cycle_exists(self.repo_id, self.topic_id, parent)? { |
| 365 | return Err(Error::Repo(format!( |
| 366 | "{} is a parent topic of {}", |
| 367 | self.topic_id, parent |
| 368 | ))); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | Ok(()) |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | pub struct UpdateTopicSynonyms { |
no test coverage detected