ZF-12496: Zend_Validate_Identical don't launches if form element value is empty


Assume we have two form fields: password and password_repeat. Both of it is not required. The last one has attached Zend_Validate_Identical validator (token parameter points to password form field). In case when values (password:'12345',password_repeat:'1') passed - anything works great. But if to pass (password:'12345',password_repeat:'') form has success validation. It looks like since password_repeat form element has no any data submitted no any validation launches at all. I am not sure if it is exactly Zend_Validation_Identical class bug against Zend_Form::isValid mechanism. Anyway, '' is not identical to '12345', thus form shouldn't be validated successfully.


If the field is not required, and no value is provided, validators are not checked. As such, you need to either (a) mark it as required, or (b) create a custom validator that checks if the "password" field is non-empty and only then runs the Identical validator.

Yes, thank you. There are also another ways to solve the trouble.

I guess this is a question of logic not a bug exactly. In described case non-required form field with no value provided needed validator to be launched though.