chrishoermann / zod-prisma-types

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

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

Open edvein-rin opened 1 month ago

edvein-rin commented 1 month 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):