CarterGrimmeisen / zod-prisma

A custom prisma generator that creates Zod schemas from your Prisma model.
MIT License
826 stars 86 forks source link

Custom Zod Schema in an Int field stills adds .int() at the end #147

Open lugrinder opened 2 years ago

lugrinder commented 2 years ago

For example, a schema like this:

model Test {
  id    Int @id @default(autoincrement())
  /// @zod.custom(z.nativeEnum(imports.State))
  state Int @default(0)
}

Where State is defined in imports like:

export enum State {
  ONE,
  TWO,
  THREE
}

Generates:

export const TestModel = z.object({
  id: z.number().int(),
  state: z.nativeEnum(imports.State).int()
})

Which is invalid because nativeEnum is number and don't have .int(). I can replace with a custom refine, but this is not the question...