Validate custom filters

This commit is contained in:
april 2024-01-11 12:31:51 -06:00
parent ab126ceb06
commit cf9784b770

View File

@ -27,6 +27,9 @@ async def retrieve_flights(user: str = "", sort: str = "date", order: int = -1,
:param filter_val: Value to filter field by
:return: List of flights
"""
if filter not in FlightDisplaySchema.__annotations__.keys():
raise HTTPException(400, f"Invalid filter field: {filter}")
filter_options = {}
if user != "":
filter_options["user"] = ObjectId(user)