I am currently working on expanding the Vuelidate object within my Vue application. Here is the current setup in my Vue Component:
import {required} from "vuelidate/lib/validators";
export default {
validations: {
...
}
}
In order to achieve this, I have created a new file called custom-validator.js
import { helpers } from "vuelidate/lib/validators";
export const OnlyDigits = helpers.regex('onlyDigits', /^\d+$/);
My goal is to import OnlyDigits
along with the predefined vuelidate validators from the custom-validator.js file.
The desired end result would be:
import {required, OnlyDigits} from 'custom-validators.js'
This is what I have attempted so far:
import { helpers } from "vuelidate/lib/validators";
import * as Validators from 'vuelidate/lib/validators'
export const OnlyDigits = helpers.regex('onlyDigits', /^\d+$/);
export default Object.assign({}, Validators, {
OnlyDigits
});