More flexible validationRules in model? |
This is a very valid architecture point, michalsn.
I would fully support getters/setters for (almost) all protected attributes, like $validationRules or $allowedFields. Moreover, it is very easy to implement and suggest to include into subsequent releases of CI4. When it comes to separation of validation logic and and list of allowed fields for create/update actions, I like the approach RubyOnRails uses in its ActiveRecord: 1. You can define generic validation rules applicable in any case, and on top of that customize them for create/update actions. Totally makes sense: https://guides.rubyonrails.org/active_re...ns.html#on 2. For $allowedFields differenciation on updated/create it offers slightly different approach: Model is allowed to have readonly attributes. Those attributes will be set only when record is created using $myModel->insert(), but ignored during $myModel->update() call. It would be cool to have $readonlyFields introduced in CI4.x. I am also happy to work on pull request. |
Messages In This Thread |
More flexible validationRules in model? - by michalsn - 02-26-2020, 11:40 PM
RE: More flexible validationRules in model? - by zahhar - 02-27-2020, 07:39 AM
RE: More flexible validationRules in model? - by MGatner - 03-01-2020, 06:17 PM
RE: More flexible validationRules in model? - by michalsn - 03-02-2020, 12:46 PM
|