Skip to content
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

Zod namespace translation #147

Open
shifenis opened this issue Jun 29, 2023 · 0 comments
Open

Zod namespace translation #147

shifenis opened this issue Jun 29, 2023 · 0 comments

Comments

@shifenis
Copy link

Hi team!

Problem

I'm using zod and zod-i18n for validate some forms. I have two locales from a static file.
I would not use a custom namespace for translate already covered case, like this one:

  z.string()
  .transform((t) => t?.trim())
  .pipe(z.string().min(1)); // Message it has to be "invalid_type_received_undefined" and not "inclusive" from zod errors

Basically i would set the error of required to min.

Tried with:

z.string().refine((t) => t.trim().length > 0, {
  message: i18next.t(`zod.errors.invalid_type_received_undefined`),
}),

But I didn't have any luck! So, the question is if there is any way to achieve this?

Version

 "zod": "^3.20.6",
 "zod-i18n-map": "^2.12.0"
  "i18next": "^22.4.15",
  "next": "^12.2.5",
  "react": "^18.2.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant