

def slug(value):
    'Validate value is a valid slug.'
    if (value is None):
        raise vol.Invalid('Slug should not be None')
    value = str(value)
    slg = slugify(value)
    if (value == slg):
        return value
    raise vol.Invalid('invalid slug {} (try {})'.format(value, slg))

dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/helpers/config_validation.py slug/original