Closed chaffinated closed 2 months ago
I think this is related to the same problem of the issue #11641
Because now it is using z.ZodObject instead of z.ZodEffect as @bryanwood said in this comment: https://github.com/withastro/astro/issues/11641#issuecomment-2285221026
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using a zod object schema to validate an action input, using
z.object({}).passthrough()
has no effect and does not allow additional keys and values.This line is the cause: https://github.com/withastro/astro/blob/main/packages/astro/src/actions/runtime/virtual/server.ts#L135C19-L135C32
Depending on the desired behavior, it may be more correct to iterate over
formData
rather thanschema.shape
.What's the expected result?
When the action input schema allows for additional keys, the validator does not strip them from the input.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-vkxmc9?file=src%2Factions%2Findex.ts
Participation