Function getJsonRpcIdValidator

  • Gets a function for validating JSON-RPC request / response id values.

    By manipulating the options of this factory, you can control the behavior of the resulting validator for some edge cases. This is useful because e.g. null should sometimes but not always be permitted.

    Note that the empty string ('') is always permitted by the JSON-RPC specification, but that kind of sucks and you may want to forbid it in some instances anyway.

    For more details, see the JSON-RPC Specification.

    Returns

    The JSON-RPC ID validator function.

    Parameters

    • Optional options: JsonRpcValidatorOptions

      An options object.

    Returns ((id: unknown) => id is null | string | number)

      • (id: unknown): id is null | string | number
      • Type guard for JsonRpcId.

        Returns

        Whether the given ID is valid per the options given to the factory.

        Parameters

        • id: unknown

          The JSON-RPC ID value to check.

        Returns id is null | string | number