diff options
-rw-r--r-- | backend/models/form.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/backend/models/form.py b/backend/models/form.py index 79d1d54..a8c5f92 100644 --- a/backend/models/form.py +++ b/backend/models/form.py @@ -13,12 +13,16 @@ class Form(BaseModel): features: t.List[str] questions: t.List[Question] + class Config: + allow_population_by_field_name = True + @validator("features") def validate_features(cls, value: t.List[str]) -> t.Optional[t.List[str]]: """Validates is all features in allowed list.""" # Uppercase everything to avoid mixed case in DB value = [v.upper() for v in value] - if not all(v in FormFeatures.__members__.values() for v in value): + allowed_values = list(v.value for v in FormFeatures.__members__.values()) + if not all(v in allowed_values for v in value): raise ValueError("Form features list contains one or more invalid values.") if FormFeatures.COLLECT_EMAIL in value and FormFeatures.REQUIRES_LOGIN not in value: # noqa |