<?php
class myCreateUserValidator extends sfValidator
{    
	public function initialize($context, $parameters = null)
	{
		// initialize parent
		parent::initialize($context);
		
		// set defaults
		$this->setParameter('create_error', 'Invalid input');
		
		$this->getParameterHolder()->add($parameters);
		
		return true;
	}
	
	public function execute(&$value, &$error)
	{
		$username = $value;
		$c = new Criteria();
		$c->add(TbluserPeer::US_USERNAME , $username);
		$user = TbluserPeer::doSelectOne($c);
		
		// nickname exists?
		if ($user)
		{
		  $error = $this->getParameter('create_error');
		  return false;
		}
		return true;
	}
}
?>