chrishoermann / zod-prisma-types

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

Umlauts and accents in rich comments break conversion #184

Closed ni-co closed 8 months ago

ni-co commented 10 months ago

Using Versions Prisma v. 5.2.0 zod-prisma-types v. 2.7.9

There is an issue with umlauts and accented characters not being converted correctly in rich comments:

E.g. this rich comment

model Project {
  /// @zod.custom.use(z.string().email({ message: "Gültige E-Mail-Adresse eingeben" }).optional())
  email    String?
}

causes the following Zod schema conversion:

export const ProjectSchema = z.object({
  /**
   * .email({ message: "Gültige E-Mail-Adresse eingeben" }).optional())
   */
  email: z.string(.nullable(),
})

Whereas this Prisma schema:

model Project {
  /// @zod.custom.use(z.string().email({ message: "Gueltige E-Mail-Adresse eingeben" }).optional())
  email    String?
}

converts correctly to this Zod schema:

export const ProjectSchema = z.object({
  email: z.string().email({ message: "Gueltige E-Mail-Adresse eingeben" }).optional().nullable(),
})
chrishoermann commented 8 months ago

@ni-co This should work now in the latest version 2.7.13