I wanted to use the Phalcon\Validation\Validator\Identical
Validator in order to Check if a Checkbox was clicked in my Formular.
But no matter what i try the validation always fails. I'm currently using Phalcon v2.0.3
$validator = new \Phalcon\Validation();
$validator->add('terms', new \Phalcon\Validation\Validator\Identical(array(
'accepted' => 'yes',
'message' => 'You need to accept the Terms of Agree'
)));
$post = array('terms' => 'yes');
$messages = $validator->validate($post);
if ($messages->count()) {
echo "Validation failed!";
}
The Validation above always fail even if the Value is identical.
Reference:
EDIT: Got the right answer in the Github Issue Ticket. The Documentation is wrong.
It is required to use value
instead of accepted