According to this part of vuelidate documentation https://vuelidate-next.netlify.app/advanced_usage.html#i18n-support, I have some issues with using vuelidate with vue-i18n and also there is a problem with Persian characters when using rules, It cannot recognize Persian letters and validate them.
I really need help using vuelidate to validate fields in Persian(Farsi) and English.
version:
“@vuelidate/core”: “^2.0.3”,
“@vuelidate/validators”: “^2.0.4”,
“vue-i18n”: “^9.11.0”
Thank a lot you for your help
here is my i18n.js
import { createI18n } from 'vue-i18n'
import en from '@/locales/en.json'
import fa from '@/locales/fa.json'
function loadLocaleMessages() {
const locales = [{ en: en }, { fa: fa }]
const messages = {}
locales.forEach((lang) => {
const key = Object.keys(lang)
messages[key] = lang[key]
})
return messages
}
export default createI18n({
locale: 'en',
fallbackLocale: 'fa',
messages: loadLocaleMessages()
})
and here is my validation.js
import * as validators from '@vuelidate/validators'
import { i18n } from "@/i18n"
const { createI18nMessage } = validators
const withI18nMessage = createI18nMessage({ t: i18n.global.t.bind(i18n) })
export const required = withI18nMessage(validators.required)
export const minLength = withI18nMessage(validators.minLength, { withArguments: true })
export const maxLength = withI18nMessage(validators.maxLength(10))```