Apply default value for string form fields if they are empty

This commit is contained in:
Yannik Rödel 2024-04-14 16:38:05 +02:00
parent 740c2fff3f
commit a0f9dd8b8f

View file

@ -172,6 +172,8 @@ def get_form_value(
result = cast(form.getfirst(name))
if isinstance(result, str):
result = result.strip()
if not result and default is not None:
return default
return result
except (TypeError, ValueError):
fail("400 Bad Request", f"Invalid value for field: {name}")