VALID_CHARS = string.lowercase + string.digits + '-.'

def is_valid_domain(domain):
    if not all(char in VALID_CHARS for char in domain.lower()):
        return False
if len(domain) > 253:
    return False
if '--' in domain:
    return False
if '..' in domain:
    return False
return True
How can I validate that a domain name conforms to RFC 1035 using Python?