I would like to create pydantic model to validate users form. one of my model values should be validated from a list of names. I succeed to create the model using enum as follow:
from enum import Enum
class Fruit(str, Enum):
APPLE = 'apple'
BANANA = 'banana'
MELON = 'melon'
from pydantic import BaseModel
class UserForm(BaseModel):
fruit: Fruit
name: str
Now I would like to switch the enum to a list of values in my code:
fruit = ['apple','banana','melon']
How can I manage to do so?
tnx