-
-
Notifications
You must be signed in to change notification settings - Fork 404
Add "search", "match" and "fullmatch" modes to Regexp validator #871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add "search", "match" and "fullmatch" modes to Regexp validator #871
Conversation
9ab5825 to
8fdd991
Compare
fe1584d to
0c355e6
Compare
| def __init__(self, regex, flags=0, message=None, mode="match"): | ||
| self.mode = self._validate_mode(mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my POV it's better to validate mode value in __init__() in order to prevent the object instantiating with invalid data. in other words, validating mode value is a check of the invariant (mode field has supported value) and thus the object must not be created/instantiated if any of invariant checks failed.
|
/poke reviewers |
|
@azmeuk please review. |
Description:
Currently
Regexpvalidator supports onlyre.matchmode, but sometimes we need to usere.fullmatchorre.searchmode.Relevant issues or pull requests:
#867
What this PR does to fix the issue:
re.fullmatchandre.searchmodes along withre.matchwith full backward compatibilityValidatorSetupErrorexception to be raised if an user is trying to set up validator in a wrong wayRegexpvalidator to cover the changesdocs/fields.rstfile to show addedmodekwarg toRegexp.__init__()