You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an array in formData contains an empty string ('') as the first element, it gets trimmed, and the resulting payload has fewer elements than expected. As a result, the indices in parseResult.value do not match the original formData.
This behavior also affects validation errors when using useForm, making it difficult to pinpoint which input has an error.
Conform version
v1.1.5
Steps to Reproduce the Bug or Issue
test("parseWithZod with array",()=>{constformData=newFormData();formData.append("animals","");formData.append("animals","dog");formData.append("animals","");formData.append("animals","cat");constresult=parseWithZod(formData,{schema: z.object({animals: z.array(z.string().optional()),}),});expect(result.status).toBe("success");expect(result.payload).toEqual({animals: ["","dog","","cat"],});});
Describe the bug and the expected behavior
When an array in formData contains an empty string (
''
) as the first element, it gets trimmed, and the resulting payload has fewer elements than expected. As a result, the indices in parseResult.value do not match the original formData.This behavior also affects validation errors when using useForm, making it difficult to pinpoint which input has an error.
Conform version
v1.1.5
Steps to Reproduce the Bug or Issue
What browsers are you seeing the problem on?
Chrome
Screenshots or Videos
No response
Additional context
This issue occurs because
''
is treated as falsy. As a result, setting values into the context is skipped until a concrete value is provided.conform/packages/conform-dom/submission.ts
Lines 103 to 104 in b0fb91d
The text was updated successfully, but these errors were encountered: