def validate_domain(self, domain):
        # Domains can't contain whitespace if they are to be used in memcached
        # keys. Seems safer to leave that as the default case regardless of
        # which backing store we use.
        if re.search("\s", domain):
            raise ValueError("Domains can't contain whitespace")

        # Domains must look like domains, ie have the structure of
        # <subdomain(s)>.<tld>. One reason for this is that bots need
        # to have valid looking emails.
        if len(domain.split(".")) < 2:
            raise ValueError("Domains must contain a '.'")

        if RealmAlias.objects.filter(domain=domain).count() > 0:
            raise ValueError("Cannot create a new realm that is already an alias for an existing realm")
dataset/ETHPy150Open zulip/zulip/zerver/management/commands/create_realm.py/Command.validate_domain/original