Respect/Validation email() don't work

1.1k Views Asked by At

I use Respect/Validation and when I use email()...the problem is:

if I validate a string: validator::email()->validate('[email protected]'); it work!

if I validate a variable: validator::email()->validate($_POST['email']); it doesn't work!

I try to check the content into $_POST['email'] and it's: [email protected]

the exact output of var_dump($_POST['email']); is: string(21) " [email protected]"

1

There are 1 best solutions below

1
On BEST ANSWER

As you can see in the output of var_dump($_POST['email']), there is a whitespace in front of the email address:

string(21) " [email protected]"

So you have to remove that from your parameter, e.g. with trim():

validator::email()->validate(trim($_POST['email']));