Skip to content

Commit

Permalink
model: defer check for mandatory attribute app_type to pydantic
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-zero committed Mar 31, 2022
1 parent 182777b commit 5111fb0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions MODAK/MODAK/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ class Optimisation(BaseModel):

@root_validator
def check_app_type(cls, values): # noqa: B902
# skip checks if the mandatory app_type is not present, pydantic checks for that afterwards
if "app_type" not in values:
return values

app_type_attr = f"app_type-{values['app_type']}"
if not values.get(app_type_attr.replace("-", "_")):
raise ValueError(
Expand Down

0 comments on commit 5111fb0

Please sign in to comment.