Confusing "Using validators with form inputs" #12702
Replies: 2 comments
-
|
I'm not sure what you mean with:
There is an opened issue in the core repo (withastro/astro#13562) related to your issue. Currently, this is working as expected (while I agree this doesn't seem ideal): empty strings are converted to null. That's why we have recently added:
But maybe we can improve the wording if this is not clear enough? I'm not sure what else we can do in docs regarding that... so we might need more details about what you were expecting to find in the docs? In the meantime, I'm not sure what the workaround is:
|
Beta Was this translation helpful? Give feedback.
-
|
I'm closing this discussion because I don't think there is anything actionable in this repository and it seems this issue is already being tracked in core. If you need help finding the best workaround for your use case, feel free to create a support thread on our Discord server where you can get more opinions! |
Beta Was this translation helpful? Give feedback.
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 I read the docs, I got confused. I was receiving an “invalid type” error because an empty string was being returned as null. Is that a valid error, or is it actually an invalid type error? How should I make it submit as an empty string instead?
I’m using z.discriminatedUnion('type', ...) but I’m still getting null for empty inputs. I’ve spent the whole day reading and I’m still not sure if I’m doing this correctly, for example, when submitting a new contact form, someone might leave a required field empty, and the hidden type is "create".
The form is submitted via Astro actions on the client side using plain JavaScript.
Beta Was this translation helpful? Give feedback.
All reactions