chrishoermann / zod-prisma-types

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

isValidDecimalInput error message path #100

Closed michiim closed 1 year ago

michiim commented 1 year ago

why do you define "path" for errors of isValidDecimalInput. I think it doesn't make sense because it affects the default behaviour. As a result, the error messages for these properties are not accessible in the same way as the messages for the other properties

export const MyModelSchema = z.object({ id: z.number(), decimal: z .union([z.number(), z.string(), DecimalJSLikeSchema]) .refine((v) => isValidDecimalInput(v), { message: 'Field "decimal" must be a Decimal', path: ['Models', 'DecimalModel'], }), });

chrishoermann commented 1 year ago

@michiim true. I'll change it and add this hint to the model in the message string.

chrishoermann commented 1 year ago

@michiim I changed this behaviour in the latest release