Skip to content
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

Clarify regex usage for constr in documentation #1396

Closed
lmcnearney opened this issue Apr 15, 2020 · 1 comment
Closed

Clarify regex usage for constr in documentation #1396

lmcnearney opened this issue Apr 15, 2020 · 1 comment

Comments

@lmcnearney
Copy link
Contributor

It might be helpful to clarify that the constr type validator's regex argument uses re.match() which only requires a partial match on the string. This personally bit me as I assumed the ^ and $ weren't required and put a length restriction in the expression but the field validated as the start of the string matched.

Updating the example in the documentation would probably cover it:

regex_str: constr(regex='^apple (pie|tart|sandwich)$')

Alternatively, it could use re.fullmatch() but that would change the behavior of the validator.

@samuelcolvin
Copy link
Member

Thanks for reporting, perhaps fullmatch would have been a good idea, but we can't really change the behaviour until v2 (if you think that's a good idea, I guess create a clear new issue).

In terms of documentation, I completely, PR very welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants