ardent
ardent copied to clipboard
Added functionality to ensure that only fields that is changed gets validated
See #37
Actually, isn't this done already by buildUniqueExclusionRules()?
Please take a look there and evaluate if it would solve the issue - and if not, why - instead of adding more code directly into the validation method.
What I meant by this PR was a way to only validate fields that gets changed.
Say I have a User:
User:
Firstname: Something (rules: min:2|max:255)
Lastname: NULL (rules: min:2|max:255)
Gender: NULL (rules: in:m,f)
The API then sends a request to update the user gender to "m". This will not be possible, because the user does not have a lastname. It will fail with: "lastname should be at least 2 characters"
It should only validate the lastname attribute if it was changed/updated.
I'm not sure if I follow your idea, @canfiax. The idea of validation is to disallow incorrect data to enter the database. If the rule states that lastname must have min:2, then it must fail if it's empty; the failure occurs only when validation is called - when saving, for instance.
I don't see a reason for this to be implemented, as it might create more issues with invalid fields not getting verified - if rules change or something was inserted externally. There's no great performance penalty as well, I think, as this is not an intensive operation and certainly not that frequent to take much computing time.