Simplify validation logic

This commit is contained in:
Alex Cabal 2025-01-15 16:16:45 -06:00
parent 38f4e34a11
commit db8d422133

View file

@ -73,9 +73,8 @@ class Contributor{
$error->Add(new Exceptions\ContributorEbookIdRequiredException()); $error->Add(new Exceptions\ContributorEbookIdRequiredException());
} }
if(isset($this->Name)){
$this->Name = trim($this->Name);
$this->Name = trim($this->Name ?? '');
if($this->Name == ''){ if($this->Name == ''){
$error->Add(new Exceptions\ContributorNameRequiredException()); $error->Add(new Exceptions\ContributorNameRequiredException());
} }
@ -83,10 +82,6 @@ class Contributor{
// Sometimes placeholders may have `'` in the name. // Sometimes placeholders may have `'` in the name.
$this->Name = str_replace('\'', '', $this->Name); $this->Name = str_replace('\'', '', $this->Name);
} }
}
else{
$error->Add(new Exceptions\ContributorNameRequiredException());
}
if(isset($this->UrlName)){ if(isset($this->UrlName)){
$this->UrlName = trim($this->UrlName); $this->UrlName = trim($this->UrlName);