Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Extend vuelidate with custom validators

I am trying to extend Vuelidate object in my Vue app. Currently I have following setup in my Vue Component.

import {required} from "vuelidate/lib/validators";

export default {
   validations: {
    ...
  }
}

I have created a new file custom-validator.js

import { helpers } from "vuelidate/lib/validators";
export const OnlyDgitis = helpers.regex('onlyDigits', /^\d+$/);

I want to import OnlyDgitis along with predefined vuelidate validators from custom-validator.js

End Result

import {required, OnlyDgitis} from 'custom-validators.js'

What I have tried

import { helpers } from "vuelidate/lib/validators";
   import * as Validators from 'vuelidate/lib/validators'
   
   export const OnlyDgitis = helpers.regex('onlyDigits', /^\d+$/);
   export default Object.assign({}, Validators, {
     OnlyDgitis       
   });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Following @EstusFlask suggestions from comments Here's how finally got the desired results

// custom-validators.js

import { helpers } from "vuelidate/lib/validators";

export const OnlyDgitis = helpers.regex('onlyDigits', /^\d+$/);

export * from 'vuelidate/lib/validators'

Now I can easily import like so,

// My component.js
import {required, OnlyDgitis} from 'custom-validators.js'

export default {
   validations: {
    ...
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!