Great library but I have run into a problem.
Unless I am somehow writing my regex wrong, I cannot get flags ( such as /i - ignore lowercase ) to work properly. It seems that the forward slash is automatically escaped with a back-slash thus invalidating the regex.
This:
^[a-zA-Z]+$/i
ends up as this:
^[a-zA-Z]+$\/i - invalid
I think a simple solution would be to allow multiple arguments for the regex as it's constructor signature is:
new RegExp(pattern : string, flags = '')
or
new RegExp(regExp : RegExp, flags = regExp.flags)this being the one you've implemented that inserts back-slashes
the validator could possible be written as such (with another colon as delimiter to pull in multiple arguments). Not certain what side effects this would have on your code:
@jamesdefant Hi
such behavior will bring more complexity, because ':' symbol may be a part of regexp. So regex flag won't be supported
you always can create your own validation rule to handle more complex cases
Great library but I have run into a problem. Unless I am somehow writing my regex wrong, I cannot get flags ( such as /i - ignore lowercase ) to work properly. It seems that the forward slash is automatically escaped with a back-slash thus invalidating the regex.
This:
^[a-zA-Z]+$/i
ends up as this:^[a-zA-Z]+$\/i
- invalidI think a simple solution would be to allow multiple arguments for the regex as it's constructor signature is:
new RegExp(pattern : string, flags = '')
or
new RegExp(regExp : RegExp, flags = regExp.flags)
this being the one you've implemented that inserts back-slashesthe validator could possible be written as such (with another colon as delimiter to pull in multiple arguments). Not certain what side effects this would have on your code:
validators={[ 'matchRegexp:^[a-zA-Z]+$:i' ]}