Replies: 2 comments 2 replies
-
|
Hi @0xaa55h! I'm Dosu and I’m helping the openapi-ts team. The Hey API Zod plugin doesn't currently support customizing validation error messages in the generated schemas [1]. However, you can handle this at the application level using Zod's built-in custom error map feature. You can set a global error map that translates all Zod messages to Czech: import { z } from 'zod';
z.setErrorMap((issue, ctx) => {
// Customize messages based on issue.code
switch (issue.code) {
case z.ZodIssueCode.too_small:
if (issue.type === 'string') {
return { message: `Musí obsahovat alespoň ${issue.minimum} znak(ů)` };
}
break;
case z.ZodIssueCode.invalid_type:
return { message: `Očekáváno ${issue.expected}, obdrženo ${issue.received}` };
// ... other cases
}
return { message: ctx.defaultError };
});Set this once at app startup and it will apply globally to all Zod validations, including those from generated schemas. Libraries like zod-i18n-map also exist and provide pre-built translations (Czech may be available or easy to contribute). To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
Beta Was this translation helpful? Give feedback.
-
|
@0xaa55h can you not use the built-in i18n to achieve this? https://zod.dev/error-customization?id=internationalization#internationalization |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I use hey-api to generate from my openapi spec together with Zod plugin. Is there a way to customize the Zod messaging, as the whole app is in Czech and not a English?

For example, here replace the default message with something more sensible to the user.
Any guidance/help much appreciated, thanks!
Beta Was this translation helpful? Give feedback.
All reactions