Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coerce.date() is not respected by safeParse #3502

Open
hongquan opened this issue May 18, 2024 · 1 comment
Open

coerce.date() is not respected by safeParse #3502

hongquan opened this issue May 18, 2024 · 1 comment

Comments

@hongquan
Copy link

We have a schema:

z.object({
  created_at: z.string().datetime().pipe(z.coerce.date())
})

and data:

{ created_at: '2024-05-17T01:08:19.550454Z' }

If call .parse, the created_at field is converted to Date, which is correct, but if call .safeParse, the created_at is still a string.

@hongquan
Copy link
Author

Seems to be difference across build.

If I use zod directly in my project, safeParse and parse give the same result.
But if I use indirectly via some 3rd-party lib, like https://github.com/muzychenka/vue3-websocket, then safeParse doesn't respect coerce, transform....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant