Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simplenotezy
Copy link

See #37

@igorsantos07
Copy link
Member

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.

@simplenotezy
Copy link
Author

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.

@igorsantos07
Copy link
Member

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants