mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
subdomain: Check for invalid characters before length.
I think it makes more sense to first tell the user that the character you are entering is invalid than telling minimum length requirement is not satisfied. Fixes #3058.
This commit is contained in:
@@ -66,12 +66,12 @@ def check_subdomain_available(subdomain: str) -> None:
|
|||||||
if is_root_domain_available():
|
if is_root_domain_available():
|
||||||
return
|
return
|
||||||
raise ValidationError(error_strings['unavailable'])
|
raise ValidationError(error_strings['unavailable'])
|
||||||
if len(subdomain) < 3:
|
|
||||||
raise ValidationError(error_strings['too short'])
|
|
||||||
if subdomain[0] == '-' or subdomain[-1] == '-':
|
if subdomain[0] == '-' or subdomain[-1] == '-':
|
||||||
raise ValidationError(error_strings['extremal dash'])
|
raise ValidationError(error_strings['extremal dash'])
|
||||||
if not re.match('^[a-z0-9-]*$', subdomain):
|
if not re.match('^[a-z0-9-]*$', subdomain):
|
||||||
raise ValidationError(error_strings['bad character'])
|
raise ValidationError(error_strings['bad character'])
|
||||||
|
if len(subdomain) < 3:
|
||||||
|
raise ValidationError(error_strings['too short'])
|
||||||
if is_reserved_subdomain(subdomain) or \
|
if is_reserved_subdomain(subdomain) or \
|
||||||
get_realm(subdomain) is not None:
|
get_realm(subdomain) is not None:
|
||||||
raise ValidationError(error_strings['unavailable'])
|
raise ValidationError(error_strings['unavailable'])
|
||||||
|
|||||||
Reference in New Issue
Block a user