© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
2 replies
space marine

Drizzle-zod createInsertSchema types

if I have a schema :
export const listings = pgTable("listings", {
  id: serial("id").primaryKey(),
  ...
  squareFeet: integer("sq_ft").notNull(),
  description: text("description").notNull(),
  ...
});
export const listings = pgTable("listings", {
  id: serial("id").primaryKey(),
  ...
  squareFeet: integer("sq_ft").notNull(),
  description: text("description").notNull(),
  ...
});


it seems like text and varchar column types get inferred as ZodString which I'd expect. However, integer, serial, dates, etc are just inferred as ZodAny. Is this expected? Do i just need to do some base checks in refine to make sure integers,booleans etc are correct?

Docs lead me to believe i should be able to apply a refine to the id field like
{ id: (schema) => schema.id.positive(), } 
{ id: (schema) => schema.id.positive(), } 


however I am getting an error positive does not exist on type 'ZodAny' where I'm assuming id should be of type ZodNumber
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

drizzle-zod createInsertSchema gives optional types
Drizzle TeamDTDrizzle Team / help
2y ago
Unexpected behaviour of drizzle-zod createInsertSchema
Drizzle TeamDTDrizzle Team / help
12mo ago
[postgres][zod] createInsertSchema
Drizzle TeamDTDrizzle Team / help
2y ago
Monorepo drizzle-zod types problem
Drizzle TeamDTDrizzle Team / help
9mo ago