from pydantic import BaseModel, Field
class TestModel(BaseModel):
name: str
level: T.Optional[int] = Field(0, ge=0, le=9)
level 字段限制只能是 0<=level <= 9 的值
from pydantic import BaseModel, Field
class TestModel(BaseModel):
name: str
level: T.Optional[int] = Field(0, ge=0, le=9)
level 字段限制只能是 0<=level <= 9 的值