Skip to content
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

Merged
merged 5 commits into from Mar 4, 2019

Conversation

Projects
None yet
3 participants
@paul-thebaud
Copy link
Contributor

paul-thebaud commented Mar 1, 2019

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.

@@ -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);

This comment has been minimized.

@derekmd

derekmd Mar 1, 2019

Contributor

RFCValidation::isValid() also accepts an object implementing __toString():

https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/RFCValidation.php#L30

This comment has been minimized.

@paul-thebaud

paul-thebaud Mar 1, 2019

Author Contributor

I changed this. Now, the validation method will first check to have a string or an object implementing __toString, before validating it using RFC.

@paul-thebaud

This comment has been minimized.

Copy link
Contributor Author

paul-thebaud commented Mar 1, 2019

Ok, thank you for the information.
I will update my pull-request to comply with this soon.

paul-thebaud added some commits Mar 1, 2019

Email validation accept string or object with __toString method
This commit will resolve the problem pointed by : #27735 (comment)

@GrahamCampbell GrahamCampbell changed the title Email validation will reject non-string values [5.8] Email validation will reject non-string values Mar 2, 2019

@taylorotwell taylorotwell merged commit d0a33d4 into laravel:5.8 Mar 4, 2019

1 check was pending

continuous-integration/styleci/pr The analysis is running
Details

taylorotwell pushed a commit to illuminate/validation that referenced this pull request Mar 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.