Ookma-Kyi
10/11/2022, 8:45 PMvar result = validateModel(
target = rc,
constraints = {
...
"password" : {
"required" : true,
"regex" : "/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)/",
"size": "6..255"
},
"passwordConfirmation" : { "required" : true, "sameAs" : "password" }
}
);
However no matter what I put in it gives the validator error: The 'password' value does not match the regular expression: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)/
. I tried testing my regex using a regex tester https://www.regextester.com/ and used the string Ok12345!
and verified it was correct.
Any ideas?Daniel Mejia
10/11/2022, 8:47 PMOokma-Kyi
10/11/2022, 9:34 PM"regex" : "(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)",
and also tried "regex" : "/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)/i",
and the same thing happened. 😞Adam Cameron
Adam Cameron
Adam Cameron
Adam Cameron
Scott Steinbeck
10/11/2022, 10:34 PM?=
a positive lookaheadAdam Cameron
Scott Steinbeck
10/12/2022, 6:39 PMOokma-Kyi
10/12/2022, 7:20 PMThe difference with mine is that I'm testing for each char type you need, plus I'm testing the length.I'm using
"size": "6..255"
to check the length, should I remove it and go with the regex?Adam Cameron
Daniel Mejia
10/12/2022, 7:32 PMOokma-Kyi
10/13/2022, 6:38 AMOokma-Kyi
10/13/2022, 2:59 PMLike I said... a) I don't know how coldbox works; b) your regex doesn't do a length check; c) plus at least initially it was a JS regex, not a CFML one.
From there it's down to you to test and report back.It seems to work if I use the exact regex
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,255}$
however if I try to remove the {6,255}
it fails. I've tried the following variations with no success:
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).$
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).
(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).
I can keep the {6, 255}
and remove the size
validator, just trying to keep my code consistent.Adam Cameron
Ookma-Kyi
10/13/2022, 3:58 PMAdam Cameron
Ookma-Kyi
10/14/2022, 1:03 AM