© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•11mo ago
Drew

drizzle-zod insert/update schema refinements type

I usually want to apply same refinements to insert and update. To avoid duplication I want to define them in an object. How can I type it properly so that it knows the type of the schema arguments, etc.?

type TableRefinements = ...

const refinements: TableRefinements = {
  foo: (schema) => schema.trim(),
} as const;

createInsertSchema(table, refinements)
type TableRefinements = ...

const refinements: TableRefinements = {
  foo: (schema) => schema.trim(),
} as const;

createInsertSchema(table, refinements)


Tried unsuccessfully to extract from createInsertSchema() parameters, but I think it may be matching the first signature with a single generic , in which the second parameter is undefined:

type TableRefinements = Parameters<typeof createInsertSchema<typeof table>>[1] // tuple has no element at index '1'
type TableRefinements = Parameters<typeof createInsertSchema<typeof table>>[1] // tuple has no element at index '1'


Much appreciated!
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 insert schema list
Drizzle TeamDTDrizzle Team / help
8mo ago
drizzle-zod: remove ID from insert schema type
Drizzle TeamDTDrizzle Team / help
3y ago
drizzle-zod update schema?
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle-zod should accept refinements on tables
Drizzle TeamDTDrizzle Team / help
6mo ago