chrishoermann / zod-prisma-types

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

[BUG] Schema is not generated with validation when comment includes Cyrillic script #251

Open edvein-rin opened 6 months ago

edvein-rin commented 6 months ago

Describe the bug The bug is another version of #118.

Cyryllic script inside a validator message failes regex during schema generation. Here is an example with Ukrainian language:

datasource db {
  provider  = "postgres"
}

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

model Court {
  id String @id @default(uuid())
  /// @zod.string.max(100, { message: "Максимальна довжина назви 100 символів" })
  name String 
  /// @zod.string.max(100, { message: "The max length is 100 characters" })
  description String
}

Expected:

export const CourtSchema = z.object({
  id: z.number().int(),
  name: z.string().max(100, { message: "Максимальна довжина назви 100 символів" }),
  description: z.string().max(100, { message: "The max length is 100 characters" }),
})

Actual:

export const CourtSchema = z.object({
  id: z.number().int(),
  /**
   * .max(100, { message: "Максимальна довжина назви 100 символів" })
   */
  name: z.string(),
  description: z.string().max(100, { message: "The max length is 100 characters" }),
})

Package versions (please complete the following information):

itka0526 commented 4 months ago

Please! Fix this issue 👍

ProGamer2711 commented 3 months ago

Hello! I recently encountered this problem too and fixed it in a fork of this repo. Here's the link: Repo If you want to, you are welcome to try and merge it into this repo.