question `@Matches` decorator with my regex shows true sometimes while false sometimes
See original GitHub issueI am using class-validator with nestjs. I have a password field like this:
@Matches(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).{6,64}$/gm, {
message:
'Password must be between 6 and 64 characters long with 1 special character and capital character each',
})
but sometimes the password passes this while sometimes it doesnt
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Why does this regex match true and false? - Stack Overflow
1 Answer 1 ... The "preceding pattern" is everything preceding the | , within the current group. So, true is the preceding pattern,...
Read more >12. Regular Expressions | Advanced - Python Courses eu
This introduction will explain the theoretical aspects of regular expressions and will show you how to use them in Python scripts. The term...
Read more >Python Regex: re.search() VS re.findall() - GeeksforGeeks
re.search() method either returns None (if the pattern doesn't match), or a re.MatchObject that contains information about the matching part of ...
Read more >Regular Expressions :: Eloquent JavaScript
A regular expression consisting of only nonspecial characters simply represents that sequence of characters.
Read more >What you can generate and how - Hypothesis! - Read the Docs
Examples from this strategy will shrink towards False (i.e. shrinking will replace True with False where possible). hypothesis.strategies.builds(target, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@windok , @rubiin Please read the following thread on the use of
g
flag. It makes the regex object stateful, which explains this bug.I guess you’ll have to avoid that flag to fix the issue.
https://stackoverflow.com/questions/6739136/consecutive-calls-to-regexp-test-fail-for-pattern-with-global-option
@Matches(‘^09[0-9]{9}’,“”,{“message”:“phone is incorrect”}) phone: string;
after regex pattern we need pass empty string and third argument be our message