How To Add The Custom Rule For Form Validation

Hi Guys,

I am new for Yii, I want to add custom rules for form validation, in short, I have to compare the text field value with database values, whether these values are less than, greater than, equal.

Please let me know if you have any idea.

Thank you in advance.

There is solution:

Declaring Validation Rules

In Rules


Your custom method

public function validatePassword($attribute,$params){

     //Your logic here.

        if( empty($this->password))


            $this->addError($attribute, 'Password cannot be blank'));