← All procedures

optional.isOk

This function tells if a result is a value.

CLI
Package
@procedures/optional · README
Path
["optional","isOk"]
CLI
mark optional isOk --r <object | object>
As data
{"$proc":["optional","isOk"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/optional/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["optional","isOk"], { r: "<r>" });
console.log(JSON.stringify(result));

From the command line

$ mark optional isOk --r <object | object>

As data, in a program

{ "$proc": ["optional", "isOk"], "input": { "r": "<r>" } }

Input

FieldTypeRequiredDefaultDescription
robject | objectyes

Output

The schema does not list fields (boolean).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "r": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "tag": {
                "type": "string",
                "const": "err"
              },
              "error": {}
            },
            "required": [
              "tag",
              "error"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "tag": {
                "type": "string",
                "const": "ok"
              },
              "value": {}
            },
            "required": [
              "tag",
              "value"
            ],
            "additionalProperties": {}
          }
        ]
      }
    },
    "required": [
      "r"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "boolean"
  }
}