0

How to use multi range in between rule or included of VeeValidate ?

i would like to validate 1-15 and 100

Eq. 5 is valid 50 is invalid 100 is valid

i try

rule.between = [[1,15],100]; not work but error message is "The XXX field must be between 1,15 and 100."

Zeing
  • 15
  • 1
  • 8

1 Answers1

1

Consider using custom validator:

import { Validator } from 'vee-validate';

// Define custom validation rule
Validator.extend('custom-val', {
    getMessage: field => `The ${field} field must be between 1,15 and 100.`,
    validate: value => value === 100 || (value >= 1 && value <= 15)
});

Then use this validation rule as:

<input type="text" name="my-field" v-validate="'custom-val'">
Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
  • i use Validator.extend('custom-val', { getMessage: field => `The ${field} field must be between 1,15 and 100.`, validate: value => value == 100 || (value >= 1 && value <= 15) }); – Zeing Aug 21 '18 at 12:19