More detailed namespace validation
Fixes namespace validation to use the proper regex for checking length, as well as showing the proper messaging if the entered namespace is invalid [Delivers #137830461]
This commit is contained in:
parent
aafcb592a6
commit
462f47924e
7 changed files with 11 additions and 14 deletions
|
@ -35,11 +35,11 @@ def validate_email(email_address):
|
|||
def validate_username(username):
|
||||
# Based off the restrictions defined in the Docker Registry API spec
|
||||
if not re.match(VALID_USERNAME_REGEX, username):
|
||||
return (False, 'Username must match expression ' + VALID_USERNAME_REGEX)
|
||||
return (False, 'Namespace must match expression ' + VALID_USERNAME_REGEX)
|
||||
|
||||
length_match = (len(username) >= MIN_USERNAME_LENGTH and len(username) <= MAX_USERNAME_LENGTH)
|
||||
if not length_match:
|
||||
return (False, 'Username must be between %s and %s characters in length' %
|
||||
return (False, 'Namespace must be between %s and %s characters in length' %
|
||||
(MIN_USERNAME_LENGTH, MAX_USERNAME_LENGTH))
|
||||
|
||||
return (True, '')
|
||||
|
|
Reference in a new issue