Create District Validation Function
Related to #19 (closed).
All good code validates inputs. You can't make a calculator that will accept input like: "joe" + 4 * False
; it just doesn't make sense!
Since the district_competition_photo_upload
function will accept an input from the URL to define which district is selected, we'll need to verify that the district is VALID (i.e., not something like western
since that just doesn't exist!). We may want to re-use this functionality in the future, so it makes sense to break it out into a function that will validate it for us.
The function should accept a string, and return a tuple of the validity (a boolean) and the sanitized district name (a string). Something like this:
def validate_district(district_name: str): -> tuple[bool, str]
# TODO
The sanitized district name should be "Title Case" and include the word "District". For example:
input: "eAstern"
output: "Eastern District"
That way, we'll be able to use it directly for the Lychee album selection.