

def validate_hostname(value, raise_exception=False):
    errors = []
    if (not re.match(HOSTNAME_REGEX, value)):
        errors.append('May only contain lowercase letters, numbers, and hyphens.')
    if ((value[0] == '-') or (value[(- 1)] == '-')):
        errors.append('May not start or end with a hyphen.')
    if (errors and raise_exception):
        raise ValidationError(errors)
    logger.debug(value)
    logger.debug(errors)
    return errors

dataset/ETHPy150Open stackdio/stackdio/stackdio/core/validators.py validate_hostname/original