Yii 2 Scenarios on insert and upadte

I am new to yii and working on a project with yii 2. I need to be able to define validation rules for the insert and update scenarios but can’t seem to get it working.

Precisely, when creating a new user, the password and password repeat fields are mandatory and must be exactly the same. How do I implement a scenario where the password and password repeat fields are neither required nor must they match when updating a record.

Any help would be greatly appreciated