Validating that a field is unique OR the same value it was before #1513
parker-codes
started this conversation in
General
Replies: 1 comment
-
Wow... saved me today! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It wasn't documented for this use case so I hope this helps someone.
Use Case
A user can visit a profile page to update their details (name, email, and phone number). If they change their email, the unique validation rule passes. If they leave it the same, however (which is usually the case), it will fail.
Solution
I had to use the
whereNot
property and provide it the existing email value, like so:(note that the docs mention using refs if you are using schema caching)
Beta Was this translation helpful? Give feedback.
All reactions