I have a login form and a registration form and the problem is with the email. If I do not add the email type in the validation rules:
'email' => 'required|unique:users,email',
and without wanting to register an email with spaces at the beginning or at the end, it registers it: for example: " [email protected] ", giving an error later when logging in.
Now, if I add the type email:
'email' => 'required|unique:users,email',
and I want to register and accidentally add a space, it tells me that the email entered is not valid.
In my opinion, shouldn't it be allowed to add with leading or trailing spaces, and then remove at check-in?
This problem was solved by Laravel in version 5.4 with the TrimStrings middleware, simply add it to
App/Kernel.php
so that it removes the spaces before and after the "strings" of the requests, like the mail in this case.Add the following line to the mentioned file:
The code for this middleware is as follows: