I am trying to create a regular expression in Vuelidate and add it to a form with several rules. The documentation does not say exactly how to use some custom rules, and I am using Composition API.
I have a field that I need to validate with a regex.
'^([A-ZÑ\x26]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1]))((-)?([A-Z\d]{3}))?$'
The field is inside a form, so I create the rules to be used later as follows.
// const rfc = helpers.regex('^([A-ZÑ\x26]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1]))((-)?([A-Z\d]{3}))?$')
I create the rules in this way
`const companyRules = {
company: {
RFC: { required, rfc },
name: { required },
line: { required },
email: { required, email },
phone: { required },
},
...
};`
And finally I use them with the form
const v$ = useVuelidate(rules, form);
But it doesn't work, as it marks me as never being valid. I tried with other simpler regex but it still never works. How should I add the rule or what should I modify in it?