Welcome Guest, Not a member yet? Register   Sign In
More flexible validationRules in model?
#1

Is there any reason why we don't support methods like setValidationRules/setValidationRule in our Model class? I think it would be very convenient to have them. The same thing with getting and setting $allowedFields variable array - we can't do it now outside the model.

Very ofter validation rules and allowed fields for inserting and updating data are different.

I know that if I want to change some validation rules I can get them in the controller (via $model->getValidationRules()), change and make validation there. But what with a scenario where I don't use controller but just a class? Making a special method for validation in every class or just creating some common class to share functionality doesn't sound like an optimal way to do it for me.

It would be much easier to just call getValidationRules, make changes and then use setValidationRules to set them back.

The other way to go would be to have separated validation rules for insert and update, but it wouldn't be so flexible like letting to set rules dynamically.

I would be happy to make a pull request.

Any thoughts? Pros/cons?
Reply


Messages In This Thread
More flexible validationRules in model? - by michalsn - 02-26-2020, 11:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB