-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support nested unions when parsing FormData #430
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I noticed it does not work correctly when the union is at the top-level of an object. Working on it. |
This works now, if the union or exactly on of its options has a default value. |
Thank you, but I'm not sure when this will be used, since your schema contains nested data and that should not be handled by the form data parser? If you still think it's needed, can you add some test cases as well, so I get a better idea of what's happening? :) |
Oh, I'm sorry for getting back at you so late. While simplifying the example schema I skipped some stuff. I will create some tests but the gist is that the schema will build more complex objects out of the posted strings. |
OK, I updated the first post, added a playground example and also some tests. Please have another look @ciscoheat |
I have a schema that looks roughly like this (updated)
This nested union was not supported for parsing FormData entries.
This PR fixes this use case by trying each union option until the first succeeds or throws an error describing the failed types.
I'm not sure if this breaks anything else. Tests pass and I didn't notice anything off.
My reasoning for having this is to get validation errors directly in one go. Otherwise I would have to parse it as a string, run a second pass and forward the issues to the main form.