How to validate email using Yii Model validation rules function code. Also how to check email exist or not using Model validation rules function in Yii.
You can create your custom validation method to fulfill your requirement.
Create a function in model class:
public function uniqueEmail($attribute, $params)
{
// Set $emailExist variable true or false by using your custom query on checking in database table if email exist or not.
// You can user $this->{$attribute} to get attribute value.
$emailExist = true;
if($emailExist)
$this->addError('email','Email already exists');
}
User this validation method in rules:
array('email', 'uniqueEmail','message'=>'Email already exists!'),