Decorator for common function argument validation

def _validate(wrapped):
    '''
    Decorator for common function argument validation
    '''
    @functools.wraps(wrapped)
    def wrapper(*args, **kwargs):
        container_type = kwargs.get('container_type')
        exec_driver = kwargs.get('exec_driver')
        valid_driver = {
            'docker': ('lxc-attach', 'nsenter', 'docker-exec'),
            'lxc': ('lxc-attach',),
            'nspawn': ('nsenter',),
        }
        if container_type not in valid_driver:
            raise SaltInvocationError(
                'Invalid container type \'{0}\'. Valid types are: {1}'
                .format(container_type, ', '.join(sorted(valid_driver)))
            )
        if exec_driver not in valid_driver[container_type]:
            raise SaltInvocationError(
                'Invalid command execution driver. Valid drivers are: {0}'
                .format(', '.join(valid_driver[container_type]))
            )
        if exec_driver == 'lxc-attach' and not salt.utils.path.which('lxc-attach'):
            raise SaltInvocationError(
                'The \'lxc-attach\' execution driver has been chosen, but '
                'lxc-attach is not available. LXC may not be installed.'
            )
        return wrapped(*args, **salt.utils.args.clean_kwargs(**kwargs))
    return wrapper