Skip to content

Commit

Permalink
Report error when email is not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
mcaskill authored Jan 15, 2021
1 parent 9913af9 commit f4220cc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Charcoal/Property/EmailProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ public function validateEmail()
if ($this['allowNull'] && !$this['required']) {
return true;
}

$val = $this->val();
$emailValid = filter_var($val, FILTER_VALIDATE_EMAIL);
return !!$emailValid;
if (!filter_var($val, FILTER_VALIDATE_EMAIL)) {
$this->validator()->error('Value is not an email address.', 'email');
return false;
}

return true;
}

/**
Expand Down

0 comments on commit f4220cc

Please sign in to comment.