.
*/
require_once 'propel/validator/BasicValidator.php';
/**
* A validator for unique column names.
*
*
*
*
*
*
*
*
*
* @author Michael Aichler
* @version $Revision: 536 $
* @package propel.validator
*/
class UniqueValidator implements BasicValidator
{
/**
* @see BasicValidator::isValid()
*/
public function isValid (ValidatorMap $map, $str)
{
$column = $map->getColumn();
$c = new Criteria();
$c->add($column->getFullyQualifiedName(), $str, Criteria::EQUAL);
$isValid = false;
try {
$table = $column->getTable()->getPhpName();
$cmd = sprintf('$isValid = %sPeer::doCount($c) == 0;', $table);
eval($cmd);
} catch(PropelException $e) {
/* what to do here ? */
}
return $isValid;
}
}