I have written a function to validate user entered password. It contains regular expression along with conditions.
conditions are
Password should be more than 8 and less than 14
Password should contain atleast a number.
Now my question, I want to pass those min and max numbers dynamically to regular expression
snippet, what I was trying :
function validatePassword(plain,minmaxValues) {
const passwordChecker = /^(?=.*[0-9])[a-zA-Z0-9!@#$%^&*]{minmaxValues.min,minmaxValues.max}$/;
return passwordChecker.test(plain);
}
When I debug, I can see passwordChecker
value is not updating with minmaxValues
.
will be appreciate, if anyone can help.
Thanks