CarterGrimmeisen / zod-prisma

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

useDecimalJs = true does not work #123

Open michiim opened 2 years ago

michiim commented 2 years ago

if useDecimalJs = true is defined, the helper schema for Decimal fields is created but not used.

details:

creates Helper (without assignment to const)

z
  .instanceof(Decimal)
  .or(z.string())
  .or(z.number())
  .refine((value) => {
    try {
      return new Decimal(value)
    } catch (error) {
      return false
    }
  })
  .transform((value) => new Decimal(value))

does not use it in schema (ex. property price)

export const product = z.object({
  id: z.string(),
  name: z.string(),
  price: z.number().nullish(),
})
ElhanM commented 5 months ago

@michiim @CarterGrimmeisen Did you find a fix for this? Is it possible for me to use the 1.0-beta branch instead on my project (which has this fix)

Can I do this?

michiim commented 5 months ago

@ElhanM zod-prisma is dead. Use https://github.com/chrishoermann/zod-prisma-types instead.