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:
Gustavo Satheler
2022-08-08 13:06:00 -03:00
committed by GitHub
parent 65a1381591
commit d90def3c4e
8 changed files with 107 additions and 45 deletions
+2
View File
@@ -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)$')