/**
* Validates all the unique indexes.
*
* This methods validates 'unique' sets of fields for the given Doctrine_Record instance.
* Pushes error to the record error stack if they are generated.
*
* @param Doctrine_Record $record
*/
public function validateUniques(Doctrine_Record $record)
{
$errorStack = $record->getErrorStack();
$validator = Doctrine_Validator::getValidator('unique');
$validator->invoker = $record;
foreach ($this->_uniques as $unique) {
list($fields, $options) = $unique;
$validator->args = $options;
$validator->field = $fields;
$values = array();
foreach ($fields as $field) {
$values[] = $record->{$field};
}
if (!$validator->validate($values)) {
foreach ($fields as $field) {
$errorStack->add($field, $validator);
}
}
}
}