Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] VarChar size is ignored #261

Open
blahetal opened this issue Jun 27, 2024 · 0 comments
Open

[BUG] VarChar size is ignored #261

blahetal opened this issue Jun 27, 2024 · 0 comments
Assignees
Labels
bug (unconfirmed) Could be a bug

Comments

@blahetal
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unconfirmed) Could be a bug
Projects
None yet
Development

No branches or pull requests

2 participants