8000 Update constr regex example to include start and end lines (#1400) · ag-python/pydantic@161a12a · GitHub
[go: up one dir, main page]

Skip to content

Commit 161a12a

Browse files
authored
Update constr regex example to include start and end lines (pydantic#1400)
This is due to the regex using `re.match()` which allows for only a partial match, fix pydantic#1396
1 parent ec25f60 commit 161a12a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

changes/1396-lmcnearney.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update constr regex example to include start and end lines

docs/examples/types_constrained.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Model(BaseModel):
2020
strip_bytes: conbytes(strip_whitespace=True)
2121

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

2626
big_int: conint(gt=1000, lt=1024)

0 commit comments

Comments
 (0)
0