From c6d9264d9487f6f207e2b6d7a3bbf7c35e005d75 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Sat, 5 Aug 2023 12:12:36 +0200 Subject: [PATCH] Mother and father can not be identical --- geneit_backend/src/controllers/members_controller.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/geneit_backend/src/controllers/members_controller.rs b/geneit_backend/src/controllers/members_controller.rs index dafab9f..3651eff 100644 --- a/geneit_backend/src/controllers/members_controller.rs +++ b/geneit_backend/src/controllers/members_controller.rs @@ -82,6 +82,8 @@ enum MemberControllerErr { MotherNotExisting, #[error("Father does not exists!")] FatherNotExisting, + #[error("Mother and father can not be identical!")] + MotherAndFatherIdentical, } fn check_opt_str_val( @@ -188,6 +190,10 @@ impl MemberRequest { if !members_service::exists(member.family_id(), mother).await? { return Err(MemberControllerErr::MotherNotExisting.into()); } + + if self.mother == self.father { + return Err(MemberControllerErr::MotherAndFatherIdentical.into()); + } } if let Some(father) = self.father {