Closed haines closed 7 months ago
remix-validated-form
@remix-validated-form/with-zod
@remix-validated-form/with-yup
zod-form-data
zod
https://codesandbox.io/p/sandbox/zod-form-data-text-bug-repro-swh7j3?file=%2Fsrc%2Findex.ts
zfd.text()
z.object
Get a "Required" error on all the fields
No response
N/A
I would expect these two schemas to be equivalent:
const zSchema = z.object({ foo: z.string().min(1, "Required"), bar: z.string().min(1, "Required"), baz: z.string().min(1, "Required"), }); const zfdSchema = z.object({ foo: zfd.text(), bar: zfd.text(), baz: zfd.text(), });
However, when validating the data { "foo": "", "bar": "" }, the former correctly produces errors on all three fields. The latter only produces an error for the first field.
{ "foo": "", "bar": "" }
This may be caused by https://github.com/colinhacks/zod/issues/3123?
Confirmed, this is a bug upstream and is resolved by https://github.com/colinhacks/zod/pull/3124.
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.2zod
: 3.22.4Please provide a link to a minimal reproduction of the issue.
https://codesandbox.io/p/sandbox/zod-form-data-text-bug-repro-swh7j3?file=%2Fsrc%2Findex.ts
Steps to Reproduce the Bug or Issue
zfd.text()
helper for multiple fields in az.object
Expected behavior
Get a "Required" error on all the fields
Screenshots or Videos
No response
Platform
N/A
Additional context
I would expect these two schemas to be equivalent:
However, when validating the data
{ "foo": "", "bar": "" }
, the former correctly produces errors on all three fields. The latter only produces an error for the first field.