zod-prisma-types
zod-prisma-types copied to clipboard
[BUG] VarChar size is ignored
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):
- zod: 3.23.8
- prisma: 5.16.0