def validate_params(req, func)
      params = req["params"]
      if !params
        params = []
      end
      e_params  = func.params.length
      r_params  = params.length
      if e_params != r_params
        msg = "Function #{func.name}: Param length #{r_params} != expected length: #{e_params}"
        return err_resp(req, -32602, msg)
      end

      for i in (0..(e_params-1))
        expected = func.params[i]
        invalid = validate("Param[#{i}]", expected, expected["is_array"], params[i])
        if invalid != nil
          return err_resp(req, -32602, invalid)
        end
      end

      # valid
      return nil
    end
def validate_params(req, func)
      params = req["params"]
      if !params
        params = []
      end
      e_params  = func.params.length
      r_params  = params.length
      if e_params != r_params
        msg = "Function #{func.name}: Param length #{r_params} != expected length: #{e_params}"
        return err_resp(req, -32602, msg)
      end

      for i in (0..(e_params-1))
        expected = func.params[i]
        invalid = validate("Param[#{i}]", expected, expected["is_array"], params[i])
        if invalid != nil
          return err_resp(req, -32602, invalid)
        end
      end

      # valid
      return nil
    end
Validates that the parameters on the JSON-RPC request match the types specified for
 this function

 Returns a JSON-RPC response hash if invalid, or nil if valid.

 * `req` - JSON-RPC request hash
 * `func` - Barrister::Function instance