Here we want to validate if the entered email is not stored in two fields of our db.
The second validator overwrites the first validator in a strange unknown way. In this case
only the second validator will work !!!

We had the bug in earlier releases of zend too and solved that issue with a copy of a our validators
Example:
$validatorUniqueEmail = new Extlib_Validate_DbUnique('users', 'email');
//$validatorUniqueEmailNew = new Extlib_Validate_DbUnique('users', 'newemail'); -> seems not to work! A ZEND BUG ?
$validatorUniqueEmailNew = new Extlib_Validate_DbUniqueCopy('users', 'newemail'); -> works

Perhaps this helps to find the issue

Comments

Posted by Ryan Mauger (bittarman) on 2009-06-05T01:56:15.000+0000

Changing Component / Name.

This is not an issue with the Zend_Validate, but is an issue of Zend_Form_Element due to its internal naming of validators. (any two validators of the same name would produce the same result).

Posted by Ryan Mauger (bittarman) on 2009-06-05T02:09:43.000+0000

This issue probably cannot be resolved without breaking BC, and this use-case can be satisfied by using the exclude field of the DB validator. Unless further use-cases can be demonstrated that make this impracticable, I would suggest defering to 2.0

Posted by Ryan Mauger (bittarman) on 2009-06-05T08:04:08.000+0000

Suggesting close as 'Wont fix'

Posted by Steve Hollis (stevehollis) on 2009-11-20T01:45:46.000+0000

Noting Matthew's comments in ZF-4811, I've attached simple patch to fix this issue for the use case described (supplying element with validator objects).

It borrows from the alias system employed by element decorators, which allows you to have multiple instances of the same decorator by supplying an alias (see "Using Multiple Decorators of the Same Type - http://framework.zend.com/manual/en/…).

To allow the passing of aliased validator class name (rather than actual instances), the lazy loader (_loadValidator) would also need to be modified in a similar fashion to _loadDecorator. The method signature would need to change in order to pass the alias, but this would not break BC.

Thoughts?

Posted by Steve Hollis (stevehollis) on 2009-11-20T09:08:58.000+0000

Scrub previous comment, this use case can be achieved using validator chains.