-
Notifications
You must be signed in to change notification settings - Fork 67
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
Support for ZodPipeline #115
Comments
Hi @jesinmat, thanks for using our library and pointing this out. Overall I'd need to check if there is persistent way to make sure that the type is correctly inferred. For example As for a fix in the meantime - yes there is one. As the message of the error suggests you can just pass // In some common file:
export const dateSchema = z.date().or(z.string().min(1).pipe(z.coerce.date()));
// In your current file:
export const WorkerSchema = z
.object({
name: z.string().min(1),
available: z.array(dateSchema),
})
.strict(); Let me know if that works for you. And I'll see if we can provide an out of the box support for pipelines. |
Thank you for your quick reply and the pull request! |
…o feature/#115-add-support-for-zod-pipelines
…for-zod-pipelines #115 added support for ZodPipeline
Hello,
I'm using Zod Pipelines according to the Zod documentation to safely handle dates. I have the following object:
This way, I can either pass date directly or a string of length at least 1 that can be converted to a date.
Using this with zod-to-openapi, the following error is generated:
Since both ZodString and ZodDate are specified, is it possible to convert this automatically?
What should I do to overcome this issue in the meantime?
And since I use this approach several times in my project, can I specify this conversion method in one place for all of them?
The text was updated successfully, but these errors were encountered: