createInsertSchema
Hi,
I have small issue with createInsertSchema function. Optional columns can have value or be undefined or null - and null type conflicts with HTMLInputElement attributes. I can't find a way to override the type to be value | undefined.
Do you have any suggestions on how to tackle this? Code below
NewRecipe type is
Just for clarity, i want to change, for example, description to be string | undefined.
2 Replies
to give more context i want to use this schema as validator in react-hook-form (shadcn-ui), would be super convenient to have it auto generated, i expect to modify the table definition quite often
maybe i can tackle this differently?
👋
You need the type generated by Drizzle and not drizzle-zod:
https://orm.drizzle.team/docs/goodies#type-api
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.