How do I create pydantic model with conditions?
I have a pydantic model. It works well when declaring new class with this model as base. The problem I have is, the
BaseUser.usernameshould have- maxlength of 32 chars
- minlength of 6 chars.
BaseUser.passwordto be fixed to 64 chars. Not less, not more.
Is that any way that I can achieve it through datatypes?
> I know that I can do it with simple "if" statements, but I want it to be a datatype in pydantic model.
from pydantic import BaseModel
class BaseUser(BaseModel):
id: int
username: str
password: str