Conditional validation not working

This is my code.




[['pdf'], 'file'],

[['pdf'], 'required', 'when' => function($model) {

    return $model->active == 1;

}],



I’ve also tried by adding


[['pdf'], 'file', 'skipOnEmpty' => true]

and


[['pdf'], 'file', 'skipOnEmpty' => false]

What am I doing wrong?

Have ou added a rule for the attribute ‘active’? Or is it safe ?