Yii2 Conditional Validator

public function rules() { return [ [['customer_type'], ConditionalValidator::className(), 'if' => [ [['customer_type'], 'compare', 'compareValue' => 'active'] ], 'then' => [ [['birthdate', 'city'], 'required'] ] ] ]; }