Closed gregpawlowski closed 8 months ago
@gregpawlowski Interesting. I was not able to make it works either.
Our code is pretty simple: new RegExp(this.regex);
and then re.test(value)
.
We will take a look.
Thank you, Andrew
Thank You @andrewtelnov , The problem is when using / in the valus.
RegExp constructor will sanitize string, flags are passed as second argument. Onlu using regex literal in javscript allows for // and passing flags at the end.
From console: new RegExp("/.@something.com/i") returns: /\/.@something.com\/i/
However passing the i as a second argument new RegExp(".@something.com", "i") return /.@something.com/i
Only regex literal syntax allows for passing in flags /.
Maybe a check can be made on the value? Check if beginning and end have / and pass in flags?
Alternatively documentation should be updated that flags cannot be passed only regex strings not objects. This would be unfortunate, one could make a custom validator for these cases. Or add a new parameter for flags in the regex validator.
@gregpawlowski I decided to implement the easiest possible solution for now. We may need a better code if more flags someone wish to set. However, at the current moment "i" is the only flag that I beleive somebody decides to use.
Thank you, Andrew
@gregpawlowski At the end, we decided to add a boolean property "insensitive".
Thank you, Andrew
Hi @andrewtelnov, I got the same issue, how can I add literal value in regexp? For example, I would check if an email ending with .edu domain. It should be case insensitive. Thanks!
Are you requesting a feature, reporting a bug or asking a question?
Bug
What is the current behavior?
Regex validator doesn't validate for case insensitive flag
What is the expected behavior?
Should validate
How would you reproduce the current behavior (if this is a bug)?
Enter the following validator in suvejs json:
When entering a test such as "test@SOMETHING.COM" the validator fails. I have tried using // instead of one /. It does not appear that case insensitive match is working.
Specify your