def validate_key(key):
    """Check if an key is a valid dotted path

    :raises: ValueError if invalid.
    """
    if len(key) is 0:
        raise ValueError('Key or a part of it may not be empty')
    if key.startswith('.') or key.endswith('.'):
        raise ValueError('Key may not start or end with a single dot: {}'.
            format(key))
    if '..' in key:
        raise ValueError('Key may not contain successive double dots: {}'.
            format(key))
