This commit is contained in:
@@ -95,11 +95,10 @@ fn check_opt_str_val(
|
||||
c: SizeConstraint,
|
||||
err: MemberControllerErr,
|
||||
) -> anyhow::Result<()> {
|
||||
if let Some(v) = val {
|
||||
if !c.validate(v) {
|
||||
if let Some(v) = val
|
||||
&& !c.validate(v) {
|
||||
return Err(err.into());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -151,11 +150,10 @@ impl MemberRequest {
|
||||
MemberControllerErr::MalformedEmailAddress,
|
||||
)?;
|
||||
|
||||
if let Some(mail) = &self.email {
|
||||
if !mailchecker::is_valid(mail) {
|
||||
if let Some(mail) = &self.email
|
||||
&& !mailchecker::is_valid(mail) {
|
||||
return Err(MemberControllerErr::InvalidEmailAddress.into());
|
||||
}
|
||||
}
|
||||
|
||||
check_opt_str_val(
|
||||
&self.phone,
|
||||
@@ -187,23 +185,20 @@ impl MemberRequest {
|
||||
MemberControllerErr::MalformedCountry,
|
||||
)?;
|
||||
|
||||
if let Some(c) = &self.country {
|
||||
if !countries_utils::is_code_valid(c) {
|
||||
if let Some(c) = &self.country
|
||||
&& !countries_utils::is_code_valid(c) {
|
||||
return Err(MemberControllerErr::InvalidCountryCode.into());
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(d) = &self.birth {
|
||||
if !d.check() {
|
||||
if let Some(d) = &self.birth
|
||||
&& !d.check() {
|
||||
return Err(MemberControllerErr::MalformedDateOfBirth.into());
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(d) = &self.death {
|
||||
if !d.check() {
|
||||
if let Some(d) = &self.death
|
||||
&& !d.check() {
|
||||
return Err(MemberControllerErr::MalformedDateOfDeath.into());
|
||||
}
|
||||
}
|
||||
|
||||
check_opt_str_val(
|
||||
&self.note,
|
||||
@@ -221,11 +216,10 @@ impl MemberRequest {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(father) = self.father {
|
||||
if !members_service::exists(member.family_id(), father).await? {
|
||||
if let Some(father) = self.father
|
||||
&& !members_service::exists(member.family_id(), father).await? {
|
||||
return Err(MemberControllerErr::FatherNotExisting.into());
|
||||
}
|
||||
}
|
||||
|
||||
member.first_name = self.first_name;
|
||||
member.last_name = self.last_name;
|
||||
|
||||
Reference in New Issue
Block a user