@router.post('/update_attributes/{username}')
def update_attributes(request: Request, username: str, email: str = Form(...)):
pass
How can I handle empty strings as input on my form? I get errors if the email
textfield on my form is not filled in.
CodePudding user response:
The ellipses
(...
) means it is required. So leaving it empty would result in errors. If you want it not to be required, you can replace the ellipses with None
like so:
@router.post('/update_attributes/{username}')
def update_attributes(request: Request, username: str, email: str = Form(None)):
pass