Let's say I have some BaseModel
, and I want to check that it's options
list is not empty. I can perfectly do it with a validator
:
class Trait(BaseModel):
name: str
options: List[str]
@validator("options")
def options_non_empty(cls, v):
assert len(v) > 0
return v
Are there any other, more elegant, way to do this?