Update the username validation to match the Docker CLI rules.

This commit is contained in:
yackob03 2013-11-15 12:31:39 -05:00
parent 82805cb7aa
commit 96921c2a29

View file

@ -1,5 +1,4 @@
import re
import urllib
INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \
'8 characters and contain no whitespace.'
@ -12,9 +11,9 @@ def validate_email(email_address):
def validate_username(username):
# Minimum length of 2, maximum length of 255, no url unsafe characters
return (urllib.quote(username, safe='') == username and
len(username) > 1 and
len(username) < 256)
return (re.search(r'[^a-z0-9_]', username) is None and
len(username) >= 4 and
len(username) <= 30)
def validate_password(password):