mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
#183 added backend validation for mealplanning timespan
This commit is contained in:
parent
f5fa4040bf
commit
0d3143402f
1 changed files with 7 additions and 1 deletions
|
@ -2,7 +2,7 @@ from datetime import date, timedelta
|
|||
from typing import List, Optional
|
||||
|
||||
from db.database import db
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, validator
|
||||
from sqlalchemy.orm.session import Session
|
||||
|
||||
from services.recipe_services import Recipe
|
||||
|
@ -41,6 +41,12 @@ class MealPlan(BaseModel):
|
|||
}
|
||||
}
|
||||
|
||||
@validator('endDate')
|
||||
def endDate_after_startDate(cls, v, values, **kwargs):
|
||||
if 'startDate' in values and v < values['startDate']:
|
||||
raise ValueError('EndDate should be greater than StartDate')
|
||||
return v
|
||||
|
||||
def process_meals(self, session: Session):
|
||||
meals = []
|
||||
for x, meal in enumerate(self.meals):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue