-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to override translation with discriminated union #30
Comments
Hi @zAlweNy26 this only solution i found is next one: But you will not have the text translated. const triggerSchema = z.discriminatedUnion('type', [
likeTriggerSchema,
dislikeTriggerSchema,
], {
errorMap: (issue, ctx) => {
console.log(issue, ctx)
if (issue.code === z.ZodIssueCode.invalid_union_discriminator) {
return { message: 'errors.trigger.unknownType' }
}
return { message: ctx.defaultError }
},
}) |
@zAlweNy26 check also this message #29 (comment) |
I saw that comment, but I think it's a bit overkill to solve that way. Is there any other way, maybe by updating this module? |
The problem is really on zod side. The author of the lib now it and as i see he work on it for the next version : Other solution wrap the schema to pass the translation composer at runtime |
Ok thanks for the clarification :) |
Description
Hi, I'm trying to override an error translation but my schema is a
z.discriminatedUnion
and I don't understand what I'm doing wrong, I'm still having the default error from the translated errors of this library.That's the schema:
I'm using Nuxt UI, so the schema is used by the
Form
component.The text was updated successfully, but these errors were encountered: