[Vuejs]-How to validate specific data in an object(Vee-validate) and show custom error message?

0👍

Of course you might need to overwrite the error messages, or add new ones. The Validator class and its instances provide an updateDictionary method. which will merge the messages with the internal dictionary, overwriting any duplicates.

import { Validator } from 'vee-validate';
const dictionary = {
  en: {
    messages:{
      alpha: () => 'Some English Message'
    }
  },
  ar: {
    messages: {
      alpha: () => 'Some Arabic Message'
    }
  }
};

Validator.updateDictionary(dictionary);

const validator = new Validator({ first_name: 'alpha' });

validator.setLocale('ar'); // now this validator will generate messages in arabic.

Here’s link of vee-validate plugin – http://vee-validate.logaretm.com/rules.html#custom-messages

Leave a comment