Update the username validation to match the Docker CLI rules.
This commit is contained in:
parent
82805cb7aa
commit
96921c2a29
1 changed files with 3 additions and 4 deletions
|
@ -1,5 +1,4 @@
|
||||||
import re
|
import re
|
||||||
import urllib
|
|
||||||
|
|
||||||
INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \
|
INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \
|
||||||
'8 characters and contain no whitespace.'
|
'8 characters and contain no whitespace.'
|
||||||
|
@ -12,9 +11,9 @@ def validate_email(email_address):
|
||||||
|
|
||||||
def validate_username(username):
|
def validate_username(username):
|
||||||
# Minimum length of 2, maximum length of 255, no url unsafe characters
|
# Minimum length of 2, maximum length of 255, no url unsafe characters
|
||||||
return (urllib.quote(username, safe='') == username and
|
return (re.search(r'[^a-z0-9_]', username) is None and
|
||||||
len(username) > 1 and
|
len(username) >= 4 and
|
||||||
len(username) < 256)
|
len(username) <= 30)
|
||||||
|
|
||||||
|
|
||||||
def validate_password(password):
|
def validate_password(password):
|
||||||
|
|
Reference in a new issue