How to use the vee-validate.Validator.localize function in vee-validate

To help you get started, we’ve selected a few vee-validate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GB28181 / EasyDarwinGo / web_src / components / AdminLTE.vue View on Github external
import VCharts from 'v-charts'
Vue.use(VCharts);

import VueClipboards from 'vue-clipboards';
Vue.use(VueClipboards);

import fullscreen from 'vue-fullscreen'
Vue.use(fullscreen);

import BackToTop from 'vue-backtotop'
Vue.use(BackToTop)

import VeeValidate, { Validator } from "vee-validate";
import zh_CN from "vee-validate/dist/locale/zh_CN";
Validator.localize("zh_CN", zh_CN);
Vue.use(VeeValidate, {
  locale: "zh_CN",
//   delay: 500,
  dictionary: {
    zh_CN: {
      messages: {
        required: field => `${field} 不能为空`,
        confirmed: (field, targetField) => `${field}${targetField} 不匹配`,
        regex: field => `${field} 不符合要求格式`
      }
    }
  }
});

import $ from 'jquery'
$.ajaxSetup({ cache: false });
github stream-labs / streamlabs-obs / app / components / shared / inputs / index.ts View on Github external
// rules https://baianat.github.io/vee-validate/guide/rules.html
const validationMessages = {
  en: {
    messages: {
      required: () => $t('The field is required'),
      min_value: (fieldName: string, params: number[]) => `The field value must be ${ params[0] } or larger`,
      max_value: (fieldName: string, params: number[]) => `The field value must be ${ params[0] } or less`,
      date_format: (fieldName: string, params: number[]) => `The date must be in ${ params[0] } format`,
      alpha_num: () => $t('This field may only contain alphabetic characters or numbers')
    }
  }
};

// Override and merge the dictionaries
Validator.localize(validationMessages);
github Tencent / bk-cmdb / src / ui / src / common / js / Validator.js View on Github external
regex: (field) => field + ' is illegal'
        },
        attributes: {
            Description: 'Description',
            Name: 'Name'
            // lifeCycle: '生命周期',
            // maintainers: '运维人员',
            // strictCharacter: '严格字符',
            // looseCharacter: '宽松字符',
            // number: '数字',
            // ipAddress: 'ip地址',
            // commonName: '名称'
        }
    }
}
Validator.localize(dictionary)

export default dictionary
github wmz1930 / Jeebase / jeebase-wechat / jeebase-wechat-vant / src / main.js View on Github external
import store from './store'

import i18n from './lang' // Internationalization
import './icons' // icon
import './errorLog' // error log
import './permission' // permission control
import './mock' // simulation data

import * as filters from './filters' // global filters

import Vant from 'vant'
import 'vant/lib/index.css'

import VeeValidate, { Validator } from 'vee-validate' // 引入校验框架
import zh_CN from '@/utils/vee-validate-zh_CN'
Validator.localize('zh_CN', zh_CN)
Vue.use(VeeValidate, {
  locale: 'zh_CN'
})

Vue.use(Vant)

// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
github aylizhiyuan / Vue-Lesson-Three / admin / src / components / Login.vue View on Github external
//设置验证的提示消息
  import { Validator } from 'vee-validate'
  //引入设置cookie的方法
  import { setToken } from "@/utils/auth"

  const dict = {
    custom: {
      user: {
        required: '您的用户名不能为空'
      },
      password: {
        required: () => '您的密码不能为空'
      }
    }
  }
  Validator.localize('en',dict) // changes the locale
    //引入发请求的模块
    import request from '@/utils/request'
    export default {
      name: "Login",
      data(){
        return {
          LoginForm:{
            user:'',
            password:''
          }
        }
      },
      methods:{
        //登录方法
        login:function(){
          //首先拿到验证成功失败的结果,如果成功了,再进行登录,如果失败了,则进行消息提示...
github ademilter / vue-firebase-example / src / main.js View on Github external
import Vue from 'vue'
import App from './App'
import router from './router'
import store from '@/store'
import VeeValidate, { Validator } from 'vee-validate'
import tr from 'vee-validate/dist/locale/tr'
import VueLoading from 'vuex-loading'
// import '@/firebase'
import { AUTH } from '@/firebase'

Vue.config.productionTip = false
Validator.localize('tr', tr)

Vue.use(VueLoading)
Vue.use(VeeValidate, {
  events: 'input'
})

let app
AUTH.onAuthStateChanged(() => {
  if (!app) {
    app = new Vue({
      el: '#app',
      router,
      store,
      vueLoading: new VueLoading({ useVuex: true }),
      template: '',
      components: { App }
github davellanedam / vue-skeleton-mvp / src / store / modules / locale.js View on Github external
setLocale({ commit }, payload) {
    commit(types.SUCCESS, null)
    commit(types.ERROR, null)
    i18n.locale = payload
    Validator.localize(payload)
    window.localStorage.setItem('locale', JSON.stringify(payload))
    commit(types.SET_LOCALE, payload)
  }
}
github WeBankPartners / open-monitor / monitor-ui / src / assets / veeValidate / VeeValidate.js View on Github external
import Vue from 'vue'
import VeeValidate, {Validator} from 'vee-validate'
import zh from 'vee-validate/dist/locale/zh_CN'
import en from 'vee-validate/dist/locale/en'

Validator.localize('en-US', en)
Validator.localize('zh-CN', zh)
Validator.localize({
  'zh-CN': {
    messages: {
      required: '不能为空',
      numeric: '仅允许数字',
      alpha:'只能包含字母字符',
      max: function (n, e) {
        return '不能超出' + e[0] + '字符'
      },
      min: function (n, e) {
        return '不能少于' + e[0] + '字符'
      },
      between: function(n,e){
        return '必须在'+e[0]+','+e[1]+'之间'
      },
      email: '必须为有效邮箱'
github ufabc-next / ufabc-next-web / web / src / main.js View on Github external
Vue.use(Vuetify)

import VCharts from 'v-charts'
Vue.use(VCharts)

import VueTheMask from 'vue-the-mask'
Vue.use(VueTheMask)

import VeeValidate, {Validator} from 'vee-validate'
Vue.use(VeeValidate);

import VueDialog from '@/helpers/VueDialog'
Vue.mixin(VueDialog)

import VeeLocale_pt_BR from 'vee-validate/dist/locale/pt_BR'
Validator.localize('pt_BR', VeeLocale_pt_BR)

import Element from 'element-ui'
Vue.use(Element)

Vue.config.productionTip = false

Axios.interceptors.response.use(null, function (error) {
  const status = error.response && error.response.status
  if (status === 401) {
    Auth.logOut()
  }

  return Promise.reject(error);
})

Axios.interceptors.request.use(function (config) {
github WeBankPartners / open-monitor / monitor-ui / src / assets / veeValidate / VeeValidate.js View on Github external
import Vue from 'vue'
import VeeValidate, {Validator} from 'vee-validate'
import zh from 'vee-validate/dist/locale/zh_CN'
import en from 'vee-validate/dist/locale/en'

Validator.localize('en-US', en)
Validator.localize('zh-CN', zh)
Validator.localize({
  'zh-CN': {
    messages: {
      required: '不能为空',
      numeric: '仅允许数字',
      alpha:'只能包含字母字符',
      max: function (n, e) {
        return '不能超出' + e[0] + '字符'
      },
      min: function (n, e) {
        return '不能少于' + e[0] + '字符'
      },
      between: function(n,e){
        return '必须在'+e[0]+','+e[1]+'之间'
      },
      email: '必须为有效邮箱'
    }