Merge modifications for more separate backend functions #69

Open
kscheidecker wants to merge 19 commits from backend/micro-services-restructuring into main
2 changed files with 19 additions and 6 deletions
Showing only changes of commit c6bb0cddb7 - Show all commits

File diff suppressed because one or more lines are too long

View File

@@ -39,3 +39,16 @@ class Preferences(BaseModel) :
max_time_minute: Optional[int] = 3*60 max_time_minute: Optional[int] = 3*60
detour_tolerance_minute: Optional[int] = 0 detour_tolerance_minute: Optional[int] = 0
def model_post_init(self, __context):
"""
Method to validate proper initialization of individual Preferences.
Raises ValueError if the Preference type does not match with the field name.
"""
if self.sightseeing.type != 'sightseeing':
raise ValueError(f'The sightseeing preference cannot be {self.sightseeing.type}.')
if self.nature.type != 'nature':
raise ValueError(f'The nature preference cannot be {self.nature.type}.')
if self.shopping.type != 'shopping':
raise ValueError(f'The shopping preference cannot be {self.shopping.type}.')