in privaterelay/validators.py [0:0]
def valid_available_subdomain(subdomain: Any) -> None:
"""Raise CannotMakeSubdomainException if the subdomain fails a validation test."""
from privaterelay.models import RegisteredSubdomain
if not subdomain:
raise CannotMakeSubdomainException("error-subdomain-cannot-be-empty-or-null")
subdomain = str(subdomain).lower()
# valid subdomains:
# have to meet the rules for length and characters
valid = _re_valid_subdomain.match(subdomain) is not None
# can't have "bad" words in them
bad_word = has_bad_words(subdomain)
# can't have "blocked" words in them
blocked_word = is_blocklisted(subdomain)
# can't be taken by someone else
taken = RegisteredSubdomain.is_taken(subdomain)
if not valid or bad_word or blocked_word or taken:
raise CannotMakeSubdomainException("error-subdomain-not-available")