Astro Info
Astro v5.6.1
Node v22.11.0
System macOS (x64)
Package Manager pnpm
Output server
Adapter @astrojs/node
Integrations @astrojs/react
simple-stream
@astrojs/tailwind
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using astro:actions to handle a form submission, an empty <input type="text" /> field is unexpectedly parsed as null rather than an empty string. This causes Zod to throw a type error (invalid_type).
{
error: [ActionInputError: Failed to validate: [
{
"code": "invalid_type",
"expected": "string",
"received": "null",
"path": [
"email"
],
"message": "Expected string, received null"
}
]]
}
What's the expected result?
An empty form input should submit an empty string, which is a valid string. I would expect Zod to throw a different error than "Expected string, received null", depending on the schema.
For example, for the shcema z.object({ email: z.string().trim().email() }).strict() I would expect an Invalid email error if an empty field is submitted, similar to this zod playground.
Astro actions didn’t work for me on StackBlitz, so here’s the CodeSandbox link to a minimal reproducible example instead.
Link to Minimal Reproducible Example
https://codesandbox.io/p/devbox/6fvnh7
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using
astro:actionsto handle a form submission, an empty<input type="text" />field is unexpectedly parsed asnullrather than an empty string. This causes Zod to throw a type error (invalid_type).What's the expected result?
An empty form input should submit an empty string, which is a valid string. I would expect Zod to throw a different error than
"Expected string, received null", depending on the schema.For example, for the shcema
z.object({ email: z.string().trim().email() }).strict()I would expect anInvalid emailerror if an empty field is submitted, similar to this zod playground.Astro actions didn’t work for me on StackBlitz, so here’s the CodeSandbox link to a minimal reproducible example instead.
Link to Minimal Reproducible Example
https://codesandbox.io/p/devbox/6fvnh7
Participation