chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
578 stars 43 forks source link

[BUG] VarChar size is ignored #261

Open blahetal opened 1 week ago

blahetal commented 1 week ago

Describe the bug I have a prisma model where a size of VarChar fields is limited to a certain number of chars. The limit is not reflected in the generated zod schema

Scheme

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "linux-musl-openssl-3.0.x", "debian-openssl-3.0.x"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator zod {
  provider       = "zod-prisma-types"
}

model contacts {
  id       Int      @id @default(autoincrement())
  name     String   @db.VarChar(50)
  surname  String   @db.VarChar(50)
  supplier String   @db.VarChar(50)
  email    String?  @db.VarChar(50)
  phone    String?  @db.VarChar(30)
  country  String   @db.VarChar(50)
  note     String?
}

Output

export const contactsSchema = z.object({
  id: z.number().int(),
  name: z.string(),
  surname: z.string(),
  supplier: z.string(),
  email: z.string().nullable(),
  phone: z.string().nullable(),
  country: z.string(),
  note: z.string().nullable(),
})

Package versions (please complete the following information):