<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _validate_params(self, req):
        '''
        Validate parameters of a jsonrpc-request.

        req - request as a jsonrpc-dict

        raises SLOJSONRPCError on validation error
        '''

        #does the method exist?
        method = req['method']
        if not method in self._methods:
            raise SLOJSONRPCError(-32601)
        fct = self._methods[method]['fct']

        #'id' is only needed for none SLOJSONRPCNotification's
        try:
            getattr(fct, '__SLOJSONRPCNotification__')
            if 'id' in req:
                logging.debug('JSONRPC: Fmt Error: no id for SLOJSONRPCNotifications')
                raise SLOJSONRPCError(-32602)
        except AttributeError:
            if not 'id' in req:
                logging.debug('JSONRPC: Fmt Error: Need an id for non SLOJSONRPCNotifications')
                raise SLOJSONRPCError(-32602)

        #get arguments and defaults for the python-function representing
        # the method
        argspec = self._methods[method]['argspec']
        args, defaults = list(argspec.args), \
            list(argspec.defaults if argspec.defaults else [])

        #ignore self and session
        if 'self' in args:
            args.remove('self')
        args.remove('session')

        #create required arguments. delete the ones with defaults
        required = list(args)
        if defaults:
            for default in defaults:
                required.pop()

        #check if we need paremeters and there are none, then error
        if len(required) > 0 and 'params' not in req:
            logging.debug('JSONRPC: Parameter Error: More than zero params required')
            raise SLOJSONRPCError(-32602)

        if 'params' in req:
            #parameters must be a dict if there is more then one
            if not isinstance(req['params'], dict) and len(required) > 1:
                logging.debug('JSONRPC: Parameter Error: "params" must be a dictionary')
                raise SLOJSONRPCError(-32602)

            if isinstance(req['params'], dict):
                #check if required parameters are there
                for key in required:
                    if not key in req['params']:
                        logging.debug('JSONRPC: Parameter Error: Required key "%s" is missing' % key)
                        raise SLOJSONRPCError(-32602)

                #check if parameters are given that do not exist in the method
                for key in req['params']:
                    if not key in required:
                        logging.debug('JSONRPC: Parameter Error: Key is not allowed "%s"' % key)
                        raise SLOJSONRPCError(-32602)