Zod unique array/array of object validation with superRefine + shadcn #11381
Unanswered
dev-SR
asked this question in
Show and tell
Replies: 2 comments
-
Hi @dev-SR, It would be better if you had codesandbox |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for sharing this, it helps me a lot ❤️ @dev-SR |
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.
Uh oh!
There was an error while loading. Please reload this page.
-
When validating arrays or arrays of objects in a dynamic form using Zod's
refine
, showing error messages withshacdn
's<FormMessage />
component was challenging. Despite attempts withrefine
, the ideal validation and error message display required a different approach.The usage of
superRefine
in Zod provided the necessary functionality to validate unique arrays or arrays of objects effectively. Coupled withshacdn
's<FormMessage />
component, the error messages were successfully displayed within dynamic form fields.Code Example:
This will show the refine error at the last dynamic array item.
Fill free to suggest better approach.
Beta Was this translation helpful? Give feedback.
All reactions