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%5Validation%5Validator%5Email.html#

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


81.1k

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



27.6k

@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



18.1k

You could simply use this:

filtervar($email, FILTERVALIDATE_EMAIL)