Would it make sense for Submission.error to return a ZodError<Schema> #365
swalker326
started this conversation in
General
Replies: 1 comment
-
Hi @swalker326. I am not sure if I follow your usage yet. Can you share an example on how you are handling the zod error object? |
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
-
Hello, working with Conform has been amazing, thank you for all of the work. In working with it, I was wondering if the submission error key should return a ZodError that matches the api of the error response generate by zod. This would allow me to write 1 type of error handling and apply it to any parse (confrom parse or Schema.safeParse). It also brings up why the object is different at all.
I think it makes sense to add fields, but when fields with the same key have different types like
error
or keys that have the same values have different keysdata
vsvalue
it requires to writing different error handling logic for parsing errors from FormData vs errors from safeParse (I use this to validate objects)An example use case from my remix projects.
So in my
useActionData
I've built several different cases that I have to handle different data types in the same key or different keys for the same data type (the second case will never actually happen in the example. I never return the data from the value key of confroms parse but in other places I do).Beta Was this translation helpful? Give feedback.
All reactions