← All procedures

json.validate

Examine a JSON value against a JSON Schema

MCPCLI
Package
@procedures/json · README
Path
["json","validate"]
CLI
mark json validate --value <any> --schema <any>
MCP tool
json.validate on the dev-tools server
As data
{"$proc":["json","validate"],"input":{}}

Use it

In TypeScript

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

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

From the command line

$ mark json validate --value <any> --schema <any>

As data, in a program

{
  "$proc": ["json", "validate"],
  "input": { "value": "<value>", "schema": "<schema>" }
}

Input

FieldTypeRequiredDefaultDescription
valueanyyesThe JSON value to examine
schemaanyyesThe JSON Schema: an object or a boolean

Output

FieldTypeRequiredDefaultDescription
validbooleanyesTrue when the check found no problem
errorsobject[]yesEach problem
uncheckedstring[]yesThe keywords of the schema that the check does not examine. Empty: the verdict is complete
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "value": {
        "description": "The JSON value to examine"
      },
      "schema": {
        "description": "The JSON Schema: an object or a boolean"
      }
    },
    "required": [
      "value",
      "schema"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "valid": {
        "type": "boolean",
        "description": "True when the check found no problem"
      },
      "errors": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "pointer": {
              "type": "string",
              "description": "The JSON Pointer of the part"
            },
            "message": {
              "type": "string",
              "description": "The problem"
            }
          },
          "required": [
            "pointer",
            "message"
          ],
          "additionalProperties": false
        },
        "description": "Each problem"
      },
      "unchecked": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "The keywords of the schema that the check does not examine. Empty: the verdict is complete"
      }
    },
    "required": [
      "valid",
      "errors",
      "unchecked"
    ],
    "additionalProperties": false
  }
}