Replies: 1 comment 1 reply
-
i18n messages are not meant to be used with either As per the docs:
For i18n localization for zod/yup you should check their ecosystems as this falls outside vee-validate responsibilities. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This regards a setup using:
The Zod validation documentation shows us that we can include messages for certain error conditions within the Zod schema. Like so:
password: zod.string().nonempty('This is required').min(8, { message: 'Too short' })
.https://vee-validate.logaretm.com/v4/integrations/zod-schema-validation#form-level-validation
The i18n documentation shows us that we can store messages for multiple locales using defineRule(), configure(), and localize().
https://vee-validate.logaretm.com/v4/guide/i18n/
However, these two don't seem to work together. I've tried the following:
Zod schema:
Both two fields return an "Invalid input" error when empty (null for string field, null/'' for number field).
My thinking here is that I add the "required" rule to the field, which should when fired lookup the message from the configuration.
I now have suspicions that I may not be passing the rules correctly to the form/fields. I've read in #3380 that validation rules are ignored when useForm is in play. However, there does not seem to be a mechanism to load the validation rules into useForm
Also, shouldn't a required field in Zod not automatically fire the required-rule? Why do I need to specify it again for VeeValidate?
Beta Was this translation helpful? Give feedback.
All reactions