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.
For Yii2 I used the following in a model called Register which will use the User Class.
public function rules()
{
return [
['Email', 'filter', 'filter' => 'trim'],
['Email', 'required'],
['Email', 'email'],
['Email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'],
];
}
You need to use targetClass and put the Namepsace for the Class User