why this custom validator not working




            ['melliCode', function ($attribute, $param){

                if(strlen($this->attribute) != 10 ){

                    Yii::$app->end();

                }

            }],



What do you mean by "not working"?

for example i put something with different length but nothing prompt me

i want a validation to get an integer with exactly 10 length character( not more and not less), the field in db is defined as string.

solved, must use $ before attribute in if condition :




if(strlen($this->$attribute) != 10 ){