def key_dependency(key, dependency):
    def validator(value):
        """Test dependencies."""
        if not isinstance(value, dict):
            raise vol.Invalid('key dependencies require a dict')
        if key in value and dependency not in value:
            raise vol.Invalid('dependency violation - key "{}" requires '
                              'key "{}" to exist'.format(key, dependency))

        return value
    return validator


# Schemas
Validate that all dependencies exist for key.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/helpers/config_validation.py/key_dependency