Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.7k
Closed
Description
Hi,
I recently upgraded a project from version3.25.76 to4.0.5 and on versions4.0.6 and later I'm seeing a change in how a schema I'm using is being validated(link to playground).
Prior to4.0.6 when using the following schema:
z.object({ id: z.union( [ z.number(), z.string().nullish() ]) .transform((val) => (val === null || val === undefined ? val : Number(val))) .pipe(z.number()) .optional()})An input that didn't contain anid property would validate but now throws an error ("id: invalid_type - Invalid input: expected number, received undefined").
It seems like maybe this was the commit that introduced the change in behavior:ede9629#diff-22c8e6df681ac92b8f6c73108cc92d6f75c13232421cb54f7024195a9b631980
Is this something that can or should be reverted back to previous v3 and early v4 behavior or do I need to work around it?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels