I have a model like :
# Imports
from pydantic import BaseModel
# Data Models
class MyModel(BaseModel):
a: str
b: str
c: str
@app.post('/endpoint_to_post')
async def post_log(my_model: MyModel):
I want to specify some constraint on this model. Indeed, I need a possible values constraint on the field C of the model MyModel.
Like:
# Imports
from pydantic import BaseModel
# Data Models
class MyModel(BaseModel):
a: str
b: str
c: str in ['possible_value_1', 'possible_value_2']
Thank for your help :)