Skip to content

Commit

Permalink
Update constr regex example to include start and end lines (#1400)
Browse files Browse the repository at this point in the history
This is due to the regex using `re.match()` which allows for only a partial match, fix #1396
  • Loading branch information
lmcnearney committed Apr 18, 2020
1 parent ec25f60 commit 161a12a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/1396-lmcnearney.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update constr regex example to include start and end lines
2 changes: 1 addition & 1 deletion docs/examples/types_constrained.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Model(BaseModel):
strip_bytes: conbytes(strip_whitespace=True)

short_str: constr(min_length=2, max_length=10)
regex_str: constr(regex='apple (pie|tart|sandwich)')
regex_str: constr(regex='^apple (pie|tart|sandwich)$')
strip_str: constr(strip_whitespace=True)

big_int: conint(gt=1000, lt=1024)
Expand Down

0 comments on commit 161a12a

Please sign in to comment.