-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP update - validation only provided elements #1560
Conversation
According to codeigniter4#1559 I write some code which allows to filter validationRules to that elements which are provided in $data. ---- Allows to filter validation rules to only that elements which are in $data passed to update method If you'd like to check only fields passed in $data during update just call: $this->update($your_id, $your_data, true); if there is 5 rules in your $validation_rules and only two of them in $your_data array then only that two elements will be checked in validation process if you pass true as a 3rd arg (if you don't provide it or set to false then update will check every rule as is now). Useful: i.e. you want to only update user nickname or password instead of passing all user attributes.
Oh, I've already see... in my commit there is also a code from my PR#1325 cuz I am using it more than a month. I think you can close PR#1325 and if you decide too please merge this one and only docs from PR1325. |
If the docs from 1325 belong with this, they should be part of this PR too. |
@lonnieezell , @jim-parry |
Missing user guide update? unit tests? |
I'd like to ask someone for help with unit tests. Have we got someone who will be able to write tests? I could make new PR ASAP with this when #1644 will be merged because probably it will be conflicted with #1644 . |
Unit test help would be me, and not for the next week too :-/ |
dosc
According to #1559 I write some code which allows to filter validationRules to that elements which are provided in $data.
Allows to filter validation rules to only that elements which are in $data passed to update method
If you'd like to check only fields passed in $data during update just call:
$this->update($your_id, $your_data, true);
if there is 5 rules in your $validation_rules and only two of them in $your_data array then only that two elements will be checked in validation process if you pass true as a 3rd arg (if you don't provide it or set to false then update will check every rule as is now).
Useful: i.e. you want to only update user nickname or password instead of passing all user attributes.
Each pull request should address a single issue, and have a meaningful title.