0
votes

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."

1

1 Answers

1
votes

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'">