[BUG]: Drizzle-Zod is not compatible with Zod 3.24.x
Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm are you using?
0.40.0
What version of drizzle-kit are you using?
0.30.5
Other packages
drizzle-zod@^0.7.0
Describe the Bug
After updating to Zod v3.24.0, which implements @standard-schema/spec, I am encountering an error when using createSelectSchema or createInsertSchema on z.infer. Below is the error message
is missing the following properties from type 'ZodType<any, any, any>': "~standard", "~validate"
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import { z } from "zod";
import { User } from "../database/schema/user.ts";
export const SelectUser = createSelectSchema(User);
export type TSelectUser = z.infer<typeof SelectUser>;
First time using drizzle, I'm having the same issue with all the create functions from drizzle-zod. Below are 2 examples.
I think the issue is actually compatibility with the latest versions of drizzle-orm. I was able to get rid of the errors by downgrading to drizzle-orm version 0.36.0. I got the idea of trying that version because the drizzle-zod package.json had "drizzle-orm": ">=0.36.0", for the peer dependency. I tried drizzle-orm 0.37.0 and above and got the same errors, so it seems to be that drizzle-zod only works with drizzle-orm 0.36.0 currently.
Never mind my last 2 comments. I now think it was an issue with Deno's node compatibility. I was able to get it working with drizzle-orm 0.41.0 after deleting deno.lock and node_modules. Not sure why that fixed my issue. Maybe it was a problem with their handling of peer dependencies.
hi @itizarsa were you able to fix this issue? i still face it on latest drizzle orm and zod
@darahask No
@itizarsa how you guys are solving this? creating zod schemas manually?
@darahask Unfortunately yes
Big importance bug!
It is a big issue, and a comment from the maintainers would be great on this.
I believe this issue comes from a TypeScript types mismatch. The creator functions return a type of BuildSchema, while everything Zod-related wants a type of ZodObject.
Hello @devbucket @elieven
I had a similar issue with [email protected] and [email protected] [email protected]. issue
Why don't you upgrade to the latest versions and try [email protected]?
If you do, make sure to do import { z } from 'zod/v4';
Hope that helps
@sevspo That works perfectly! Thanks for the advice!
If you're still using Zod v3, stick with [email protected].
To use Zod v4, upgrade to [email protected].
See the v0.8.0 changelog for details.
The error is still present
"drizzle-orm": "0.44.1", "drizzle-zod": "0.8.2", "zod": "^3.25.49",
@pomazanbohdan Could you send an example of code that doesn't work with the dependency versions you listed? The initial issue might be solved and you may have encountered a different issue, so I need to see what kind of error you're getting with what code.
My error fix after update package zod https://github.com/drizzle-team/drizzle-orm/issues/4604