mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
Add to upper function for strings and bytes (#4165)
* feat: add to upper function for strings and bytes * docs(changes): add message for change * fix: add constr upper on types * fix: add constr upper on types * feat: add examples and doc usage * test: add test to upper for types * chore: apply suggestions from code review Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com> * chore(docs): reorder `anystr_upper` to under `anystr_lower` * fix(test): adjust parametrizes to constrained bytes upper * refactor: use pytest parametrize for unify test constrained str upper * refactor: use pytest parametrize for unify test constrained str lower * refactor(test): use pytest parametrize for unify test any str upper * refactor(test): use pytest parametrize for unify test any str lower * refactor(test): use pytest parametrize for unify test constrained bytes lower * refactor(test): use pytest parametrize for unify test any str strip whitespace * refactor(test): change test signatures to improve readability Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
This commit is contained in:
@@ -22,10 +22,12 @@ from pydantic import (
|
||||
|
||||
|
||||
class Model(BaseModel):
|
||||
upper_bytes: conbytes(to_upper=True)
|
||||
lower_bytes: conbytes(to_lower=True)
|
||||
short_bytes: conbytes(min_length=2, max_length=10)
|
||||
strip_bytes: conbytes(strip_whitespace=True)
|
||||
|
||||
upper_str: constr(to_upper=True)
|
||||
lower_str: constr(to_lower=True)
|
||||
short_str: constr(min_length=2, max_length=10)
|
||||
regex_str: constr(regex=r'^apple (pie|tart|sandwich)$')
|
||||
|
||||
Reference in New Issue
Block a user