yii2 custom validation not working

here is my code :




public function rules()

    {

        return [

            [['iscompany'], 'boolean'],

            [['name', 'lname', 'national_code', 'address', 'father_name', 'bc_place', 'bc_date', 'postal_code'], 'required'],


            ['national_code', 'validateNationalCode', 'skipOnEmpty' => false, 'skipOnError' => false],


        ];

    }

public function validateNationalCode($attribute)

    {

        $this->addError($attribute, Yii::t('app', "must be true format"));

    }



(for testing pupose ofcourse)

but this rule does not show anything

any advice?

I think you have to give an additional parameter $params to your validation-function.

See http://www.yiiframework.com/doc-2.0/guide-input-validation.html#inline-validators