16 lines
582 B
Python
16 lines
582 B
Python
import string
|
|
|
|
|
|
def validate_cat_name(name, auto_gen=False):
|
|
ALLOWED = set(string.ascii_letters + string.digits)
|
|
if not auto_gen:
|
|
if len(name) < 4 or len(name) > 24:
|
|
return "Your cat's name must be 4-24 characters long."
|
|
else:
|
|
if len(name) > 9:
|
|
return "Your cat's name must be below 9 characters long."
|
|
if not all(c in ALLOWED for c in name):
|
|
return "Your cat's name can only have letters and numbers."
|
|
if not any(c in string.ascii_letters for c in name):
|
|
return "Your cat's name needs at least 1 letter."
|