asweigart / asweigart/pyinputplus
allowRegexes is not working properly
- Dominant language
- Python
- Stars
- 114
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
Hi @asweigart, Hi @all,
I recently found a bug (or at least a documentation gap) in this module.
For test purposes, I wrote an input validation where the user has to type in a password with a specific pattern (allowed symbols and minimal/maximal length). If I only use the `allowRegex` parameter it isn't working properly:
code:
```python
password = pyip.inputStr(prompt='Type in your password: ', allowRegexes=[r"[A-Za-z0-9-_]{6,18}"], blockRegexes=[r"."])
```
log:
```bash
Type in your password: $hort
```
It's only working, if the `blockRegex` is set too:
code:
```
password = pyip.inputStr(prompt='Type in your password: ', allowRegexes=[r"[A-Za-z0-9-_]{6,18}"], blockRegexes=[r"."])
```
log:
```
Type in your password: $short
This response is invalid.
```
Maybe the code has to be updated or the documentation has to be changed.
Thanks.
Kind Severin
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the two inputStr examples from the issue and then trace the allowRegexes and blockRegexes handling in the input validation implementation. Done means the documented password pattern behaves consistently when allowRegexes is used alone, or the documentation clearly explains the required configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100