Unique validator in custom model

I am Newbie to Yii, so pardon if its too basic…

I have defined rule as


which gives me

class and its behaviors do not have a method or closure named "getTableSchema".

which is obvious.

Question is, How do I point this rule to check into user_name column of user table?

You can use the targetClass and targetAttribute properties to define the class(table) and attribute to check for uniqueness

[‘email’, ‘unique’, ‘targetClass’=>'common\models\User ‘targetAttribute’ => ‘email’]