fix(matches): prevent regex state from breaking following validations by fedeci · Pull Request #1975 · validatorjs/validator.js
Conversation
| pattern = new RegExp(pattern, modifiers); | ||
| } | ||
| return pattern.test(str); | ||
| return !!str.match(pattern); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using Array.isArray(str.match(pattern)) or str.match(pattern) !== null since the possible return values of .matches are Array or null?
The result is obviously the same, but semantically seems more appropriate to me :)
And maybe they'll be more inclined to accept the PR :)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly find that excessively verbose and probably won't be a blocker for the pr. Let's see what the maintainers think.
tux-tn
left a comment
•
Loading
tux-tn
left a comment
•
Loading
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good for you, really sorry for the delay @fedeci !
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fedeci
deleted the
fix/regex-state
branch
This was referenced
Jun 3, 2024This was referenced
Jun 14, 2024This was referenced
Jun 20, 2024This was referenced
Jul 10, 2024This was referenced
Jul 19, 2024This was referenced
Aug 30, 2024This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters