We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

How to use single Phalcon\Validation\Validator\Email ?

Following code will always give false, more over, according to docs first parameter must be a validator.. validator in validator?


$validator = new Phalcon\Validation\Validator\Email();
var_dump($validator->validate($validator, $email)));


Validation classes are not intended to be used as stand-alone classes you need the Phalcon\Validation class to orchestrate the validation:




Can you briefly explain the benefits of such approach. At first sight, this looks like an overhead.

I'm forced to define an array of incoming data ($_POST) and key of that array that contains data being validated. How can this be a good idea?

Thanks, Temuri


You could simply use this:

filter_var($email, FILTER_VALIDATE_EMAIL)