Skip to content

Configuration

Oscar edited this page Sep 3, 2018 · 3 revisions

The only configurable part of the validator is the internationalization messages.

Messages

You can customize the messages by defining the variable validationMessages as object with the messages per rule in the Vue component. It will mix and replace the messages specified.

validationMessages: {
   type: 'This is not a valid {rule}',
   required: 'This field is required',
   regexp: 'This is no a valid value',
   min: 'Minimun value is {rule}',
   max: 'Maximun value is {rule}',
   minlen: 'Minimun length is {rule}',
   maxlen: 'Maximun length is {rule}',
   length: 'Length must be {rule}',
   equals: 'Must equal the field {rule}',
   enum: 'Must be one of {rule}'
}

Another way to do it on the fly is with the following method:

let messages: {
   type: 'This is not a valid {rule}',
   required: 'This field is required',
   regexp: 'This is no a valid value',
   min: 'Minimun value is {rule}',
   max: 'Maximun value is {rule}',
   minlen: 'Minimun length is {rule}',
   maxlen: 'Maximun length is {rule}',
   length: 'Length must be {rule}',
   equals: 'Must equal the field {rule}',
   enum: 'Must be one of {rule}'
}

this.$vmv.$setMessages(messages);
Clone this wiki locally