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

How does i18n work when validators are chained? #1224

Open
nehalshah50 opened this issue Feb 11, 2024 · 0 comments
Open

How does i18n work when validators are chained? #1224

nehalshah50 opened this issue Feb 11, 2024 · 0 comments

Comments

@nehalshah50
Copy link

nehalshah50 commented Feb 11, 2024

I followed the i18n support guide here https://vuelidate-next.netlify.app/advanced_usage.html#i18n-support and have the basic solution working fine. But I am need of having a validator which does not(sameAs) and I am trying to integrate this with i18n support. But I can't make it work with validation message defined in the locale file

I have following in my i18-validators.js

export const not = withI18nMessage(validators.not, {
  withArguments: true
})

export const sameAs = withI18nMessage(validators.sameAs, {
  withArguments: true
})

I am having following in my .vue fle

notSameAsCurrent: not(
      sameAs(computed(() => chgPwdModel.value.currentPassword))
    ),

and have following in my en.json locale file

"validations": {
    "required": "{property} is required",
    "minLength": "{property} must have minimum of {min}",
    "maxLength": "{property} can not have more than {max}",
    "minValue": "{property} must be greater than {min}",
    "maxValue": "{property} must be less than {max}",
    "between": "{property} must be between {min} and {max}",
    "email": "Enter valid email address",
    "sameAs": "{property} must be same as {otherName}",
    "not": "{property} must not be same as {otherName}",
    "notSameAsCurrent": "{property} xxx"
  }

How do I get access to model properties & param when validators are chained together?

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

No branches or pull requests

1 participant