availity-reactstrap-validation
availity-reactstrap-validation copied to clipboard
regex with options arguments attached fails silently, causing onInvalidSubmit to fire
<AvField label='Add Link' validate={{
pattern:{ value: /(^|\s)((https?:\/\/)[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi, errorMessage:'Invalid URL entered' },
maxLength:{ value: 2048, errorMessage:'URL\'s longer than 2048 characters are not accepted' },
required: { value: true, errorMessage:'Enter a URL' }
}} />
if omit the gi modifier to the regex, the field works correctly.
Can you try using new RegExp?
We are using lodash's isRegExp to determine if a regex is provided directly.
Can you try using new RegExp? We are using lodash's isRegExp to determine if a regex is provided directly.
why complicate things with useless library functions, when native javascript can tell you what something is using the instanceof operator?
/a/gi instanceof RegExp // true
_.isRegExp(/(^|\s)((https?:\/\/)[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi); // true as well, which is why this is interesting.
Hmm, that is truly strange. were you able to reproduce? if not, then i wonder if it could have been something off with babel or webpack. i've noticed quite a few side effects/bugs related to the latest webpack/babel this project is based on.
webpack version : 4.41.0
babel core version: 7.6.0