-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.8] Email validation will reject non-string values #27735
[5.8] Email validation will reject non-string values #27735
Conversation
@@ -626,7 +626,7 @@ protected function extractDistinctValues($attribute) | |||
*/ | |||
public function validateEmail($attribute, $value) | |||
{ | |||
return (new EmailValidator)->isValid($value, new RFCValidation); | |||
return is_string($value) && (new EmailValidator)->isValid($value, new RFCValidation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RFCValidation::isValid()
also accepts an object implementing __toString()
:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this. Now, the validation method will first check to have a string or an object implementing __toString, before validating it using RFC.
Ok, thank you for the information. |
This commit will resolve the problem pointed by : #27735 (comment)
This commit will resolve the problem pointed by : laravel/framework#27735 (comment)
In Laravel 5.7, giving a non-string value to a validator was returning a validation error, but in Laravel 5.8, it throw an ErrorException with "Array to string conversion".
This pull-request fix this by checking that the value to validate is a string (using is_string method) or an object which has the __toString method, before validating it using Egulias EmailValidator.