ardent icon indicating copy to clipboard operation
ardent copied to clipboard

Added functionality to ensure that only fields that is changed gets validated

Open simplenotezy opened this issue 10 years ago • 3 comments

See #37

simplenotezy avatar Feb 24 '15 20:02 simplenotezy

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.

igorsantos07 avatar May 09 '15 18:05 igorsantos07

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.

simplenotezy avatar Feb 08 '16 11:02 simplenotezy

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.

igorsantos07 avatar Mar 10 '16 04:03 igorsantos07