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
import{describe,expect,test}from'vitest';import{z}from'zod';import{zfd}from'zod-form-data';describe('zfd',()=>{test.each([{name: 'repeatable() before text()',// this schema worksschema: zfd.formData({field1: zfd.repeatable(),field2: zfd.text(),}),},{name: 'text() before repeatable()',// this schema does not workschema: zfd.formData({field2: zfd.text(),field1: zfd.repeatable(),}),},])('validates form data when a schema is defined with $name',async({ schema })=>{constdata=newFormData();data.append('field1','');data.append('field2','');constresult=awaitschema.safeParseAsync(data);expect(result.success).toBe(false);if(result.success){thrownewError('Expected failure but got success');}else{consterrors=result.error.flatten()asz.inferFlattenedErrors<typeofschema>;expect.soft(errors.fieldErrors.field1).toEqual(['Required']);expect.soft(errors.fieldErrors.field2).toEqual(['Required']);}});});
Expected behavior
It shouldn't matter in which order the form fields are defined in the schema.
All validation issues should always be detected in one go.
Which packages are impacted?
remix-validated-form
@remix-validated-form/with-zod
@remix-validated-form/with-yup
zod-form-data
What version of these packages are you using?
zod-form-data: 2.0.2
Please provide a link to a minimal reproduction of the issue.
https://stackblitz.com/edit/vitest-dev-vitest-bfrru6?file=test%2Fbasic.test.ts&view=editor
Steps to Reproduce the Bug or Issue
Expected behavior
It shouldn't matter in which order the form fields are defined in the schema.
All validation issues should always be detected in one go.
No matter if schema is defined as:
or as:
Screenshots or Videos
No response
Platform
Additional context
Could be related to my previous reported issue: #358
The text was updated successfully, but these errors were encountered: