mirror of
https://github.com/withastro/astro.git
synced 2025-02-10 22:38:53 -05:00
Fix action form parsing for .nullish (#11452)
This commit is contained in:
parent
83a41d7277
commit
d14f5d9573
2 changed files with 7 additions and 2 deletions
5
.changeset/new-mails-prove.md
Normal file
5
.changeset/new-mails-prove.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes an issue where using .nullish() in a formdata Astro action would always parse as a string
|
|
@ -124,8 +124,8 @@ export function formDataToObject<T extends z.AnyZodObject>(
|
|||
const obj: Record<string, unknown> = {};
|
||||
for (const [key, baseValidator] of Object.entries(schema.shape)) {
|
||||
let validator = baseValidator;
|
||||
if (baseValidator instanceof z.ZodOptional || baseValidator instanceof z.ZodNullable) {
|
||||
validator = baseValidator._def.innerType;
|
||||
while (validator instanceof z.ZodOptional || validator instanceof z.ZodNullable) {
|
||||
validator = validator._def.innerType;
|
||||
}
|
||||
if (validator instanceof z.ZodBoolean) {
|
||||
obj[key] = formData.has(key);
|
||||
|
|
Loading…
Add table
Reference in a new issue