public function checkValid()
    {
        // error code/message already set
        if ($this->error_code && $this->error_message) {
            return false;
        }

        // missing jsonrpc or method
        if (!$this->json_rpc || !$this->method) {
            $this->error_code = self::ERROR_INVALID_REQUEST;
            $this->error_message = "Invalid Request.";
            return false;
        }

        // reserved method prefix
        if (substr($this->method,0,4) == 'rpc.') {
            $this->error_code = self::ERROR_RESERVED_PREFIX;
            $this->error_message = "Illegal method name; Method cannot start with 'rpc.'";
            return false;
        }

        // illegal method name
        if (!preg_match(self::VALID_FUNCTION_NAME, $this->method)) {
            $this->error_code = self::ERROR_INVALID_REQUEST;
            $this->error_message = "Invalid Request.";
            return false;
        }

        // mismatched json-rpc version
        if ($this->json_rpc != "2.0") {
            $this->error_code = self::ERROR_MISMATCHED_VERSION;
            $this->error_message = "Client/Server JSON-RPC version mismatch; Expected '2.0'";
            return false;
        }

        // valid request
        return true;
    }