I'm setting up a user registration page, and am validating on the username field which checks firstly if the user doesn't already exist, secondly if the username isn't a reserved one. My problem is when I attach the two validators to the form element it ignores the second validation. The second validation will only work if the first validation is removed. Is this a bug? If so, how can I fix it?
Below are the validators:
$validator = new Zend_Validate_Db_NoRecordExists(
array(
'table' => 'users',
'field' => 'username'
)
);
$validator->setMessage('Username %value% already exists', Zend_Validate_Db_Abstract::ERROR_RECORD_FOUND);
$reserved_validator = new Zend_Validate_Db_NoRecordExists(
array(
'table' => 'reserved_users',
'field' => 'name'
)
);
$reserved_validator->setMessage('Username %value% is not available', Zend_Validate_Db_Abstract::ERROR_RECORD_FOUND);
Then on the element I have :
->addValidator($validator)
->addValidator($reserved_validator)