auto-converting non-lists to list values.

This commit is contained in:
Max Metz 2024-09-09 11:55:05 +02:00
parent 8028382e79
commit 61b00b8b22

View File

@ -25,6 +25,7 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t
# the following conversion snipped ensures a dictionary output
if isinstance(errors, (str,list)):
errors = {"undefined_schema":errors}
errors = {k:v if isinstance(v,list) else [v] for k,v in errors.items()}
# hence, errors always has the following type: dict[str, list[str]]