XOR with Zod in Prisma 4.11 with Without<...>
type
#2171
Replies: 3 comments 5 replies
-
Perhaps something like this? type Foo = {
foo: string
bar: number
}
const schema = z.object( {
foo: z.string(),
bar: z.number(),
} ) satisfies z.ZodType<Foo>
schema.pick // exists
schema.omit // exists
schema.extend // exists
schema.merge // exists
schema.partial // exists If you found my answer satisfactory, please consider supporting me. Even a small amount is greatly appreciated. Thanks friend! 🙏 |
Beta Was this translation helpful? Give feedback.
-
With the package combination: I'm currently getting this error: can somone suuport? |
Beta Was this translation helpful? Give feedback.
-
any updates on this. I am in this same issue... |
Beta Was this translation helpful? Give feedback.
-
I've built a generator for prisma (zod-prisma-types) that throws a type error since prisma updated their
XOR
type in 4.11:before this type update the following zod schema worked without problems:
so a simple union was sufficient to satisfy typescript. in Prisma 4.11 typescript now throws the following error because, as I see it, the
Without<...>
type can not be satisfied with a union anymore:I'm currently a bit stuck on how to solve this issue because I don't really know how to implement the
Without<...>
type especially because thez.ZodType<...>
does not provide the object helper methods that would have been my first guess on how to approach this. Any help is appreciated.Beta Was this translation helpful? Give feedback.
All reactions