0

I try to create a regex for nr. of decimal of a number and the number of decimal will be pass from variable.

(Ex: 123.4545)-> 4decimals

const regex = 4;
const decimalValidation = helpers.regex('decimalValidation',/^\d*(\.\d{1,4})?$/);  //Insted of 4 ,I have to replace with regex const.
Beusebiu
  • 1,433
  • 4
  • 23
  • 68
  • Is this Vuelidate? Are you aware you can use a custom function, like `const decimalValidation = (value) => { const match = value.match(/^\d*(\.\d+)?$/); return match !== null && (!match[1] || match[1].length <= regex); };`? – Ry- Jan 13 '20 at 14:39
  • I wasn't , Thank you! – Beusebiu Jan 13 '20 at 14:42

0 Answers0