cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Identical Validator does not work

Open alphanyx opened this issue 11 years ago • 6 comments

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.

alphanyx avatar Jul 01 '15 07:07 alphanyx

@alphanyx You must use parameter value instead of accepted

KorsaR-ZN avatar Jul 01 '15 08:07 KorsaR-ZN

So the Documentation is wrong?

alphanyx avatar Jul 01 '15 08:07 alphanyx

@alphanyx yes!

@phalcon Where better to fix in the documents or in the code?

KorsaR-ZN avatar Jul 01 '15 08:07 KorsaR-ZN

In the code please: https://github.com/phalcon/cphalcon/blob/2.0.x/phalcon/validation/validator/identical.zep

andresgutierrez avatar Jul 01 '15 13:07 andresgutierrez

Fixed in the 2.0.x branch

andresgutierrez avatar Jul 02 '15 03:07 andresgutierrez

For everybody who use the CSFR vokuro example please make sure you change value to accepted after upgrading to 2.0.4. Or all CSFR check will fail. (Took me some time to find out what happend ;))

ruudboon avatar Jul 08 '15 09:07 ruudboon