DT
Drizzle Team•16mo ago
c1re_

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(), } however I am getting an error positive does not exist on type 'ZodAny' where I'm assuming id should be of type ZodNumber
1 Reply
c1re_
c1re_OP•16mo ago
ah, my packages were outdated. just incase anyone runs into the same issue... 😅
Want results from more Discord servers?
Add your server