DT
Drizzle Team14mo ago
tc

drizzle-zod with custom types

I have defined opaque types in my application and have implemented those in the drizzle schema (awesome and easy to use!). The opaque types are defined using zods Brand feature i.e. z.string().uuid().brand<"SomeId">(); I have that defined in the drizzle schema as someId: uuid("id").$type<SomeId>().notNull() When I use drizzle-zod to create the schema and infer the type, it's coming back as a z.ZodString rather than z.ZodBranded. Is this a bug, a feature that is in development, or simply not supported and I need to override these types?
4 Replies
rphlmr ⚡
rphlmr ⚡14mo ago
I think the type generated is related to the scalar type of the column, so, string. Maybe it could be a feature request.
Ben-xD
Ben-xD5mo ago
I've got a highly related problem, if you don't mind 🙂 I'm using a custom type (e.g. citext), but drizzle-zod will return that field as unknown instead of string. Does anyone know why?
import { customType } from "drizzle-orm/pg-core";

export const citext = customType<{ data: string }>({
dataType() {
return "citext";
},
});
import { customType } from "drizzle-orm/pg-core";

export const citext = customType<{ data: string }>({
dataType() {
return "citext";
},
});
Ben-xD
Ben-xD5mo ago
Stack Overflow
How to use drizzle-zod with custom types?
I have a custom type (e.g. citext) but drizzle zod is treating it as unknown: import { customType } from "drizzle-orm/pg-core"; export const citext = customType<{ data: string }>({
Ben-xD
Ben-xD5mo ago
Stack Overflow
How to use drizzle-zod with custom types?
I have a custom type (e.g. citext) but drizzle zod is treating it as unknown: import { customType } from "drizzle-orm/pg-core"; export const citext = customType<{ data: string }>({
Want results from more Discord servers?
Add your server