**** Validators ****
array('name','match','pattern' => '/^[a-zA-Z\s]+$/','message' => 'Только английские буквы'),
array('name','filter', 'filter'=>'strtolower'),
array('image','file','allowEmpty'=>true,'maxFiles'=>10,'types'=>'png,jpg,jpeg'),
array('text','filter','filter'=>array($obj=new CHtmlPurifier(),'purify')),
**** Own validator ****
public function passwordStrength($attribute,$params)
{
if ($params['strength'] === self::WEAK)
$pattern = '/^(?=.*[a-zA-Z0-9]).{5,}$/';
elseif ($params['strength'] === self::STRONG)
$pattern = '/^(?=.*\d(?=.*\d))(?=.*[a-zA-Z](?=.*[a-zA-Z])).{5,}$/';
if(!preg_match($pattern, $this->$attribute))
$this->addError($attribute, 'your password is not strong enough!');
}
**** XSS ****
$p = new CHtmlPurifier();
$p->options = array('URI.AllowedSchemes'=>array(
'http' => true,
'https' => true,
));
$text = $p->purify($text);
//-------------------
//Валидация как фильтра
array('text','filter','filter'=>array($obj=new CHtmlPurifier(),'purify'))