We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 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?

https://phalcon-docs-ru.readthedocs.org/ru/latest/api/Phalcon_Validation_Validator_Email.html#

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


98.9k

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

https://github.com/phalcon/cphalcon/blob/1.0.0/unit-tests/ValidationTest.php#L285



51.3k

@Phalcon

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



32.2k

You could simply use this:

filter_var($email, FILTER_VALIDATE_EMAIL)