chrishoermann / zod-prisma-types

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

Regex generation does not support alternate (`|`) operator #166

Closed justinforlenza closed 11 months ago

justinforlenza commented 11 months ago

When using the alternate (|) operator in a regex it does not get properly generated.

For example:

model X {
  time String /// @zod.string.regex(/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/)
}

Will generate the following:

export const XSchema = z.object({
  /**
   * .regex(/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/)
   */
  time: z.string(),
})

I believe this relates to #78 in that regex needs to be tweaked to accept the pipe symbol.