Added field validation for preferences
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m31s
				
			
		
			
				
	
				Run linting on the backend code / Build (pull_request) Failing after 19s
				
			
		
			
				
	
				Run testing on the backend code / Build (pull_request) Failing after 19m47s
				
			
		
			
				
	
				Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 33s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m31s
				
			Run linting on the backend code / Build (pull_request) Failing after 19s
				
			Run testing on the backend code / Build (pull_request) Failing after 19m47s
				
			Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 33s
				
			This commit is contained in:
		
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -39,3 +39,16 @@ class Preferences(BaseModel) : | ||||
|  | ||||
|     max_time_minute: Optional[int] = 3*60 | ||||
|     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}.') | ||||
		Reference in New Issue
	
	Block a user