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

Interpolate custom messages without refine/params method #212

Open
kluplau opened this issue Aug 16, 2024 · 0 comments
Open

Interpolate custom messages without refine/params method #212

kluplau opened this issue Aug 16, 2024 · 0 comments

Comments

@kluplau
Copy link

kluplau commented Aug 16, 2024

Hi,

I wanted to display some custom errors from my API.

I made a name space called formErrors that contains these generic errors, and when an error occurs I then check if formErrors has an translation for it and if so, I translate it with i18next.

However, some erorrs needs more context (parms), like my custom TOO_SHORT_PASSWORD that is a Zod type like string().min(8, "TOO_SHORT_PASSWORD"), which in my formErrors hans a translated string `The password should be at least {{ minimum }} characters long".

This works, I think I have misunderstood something, or done it wrong. With my implementation I miss out of some of the functionality of this package like exact, inclusive and not_inclusive.

Is there a way I can have custom error messages, with interpolation, that doesn't require the refine/params method?

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