On this page
Sommatic Docs
Open portal

Validate Data

Validates the input payload against a JSON Schema (Draft-07).

View as Markdown
Open in
Data Available data.validate Version 1.0.0 Execution: sync

Validates the incoming payload against a JSON Schema with Ajv 8 and routes the unchanged payload to valid or invalid.

Ensures data quality and integrity by strictly enforcing structure, types, and constraints before proceeding in the workflow. If validation fails, execution is routed to the 'invalid' port with detailed error metadata.

Features:

  • Uses AJV (Another JSON Validator) under the hood.
  • Supports full JSON Schema specification.
  • Provides detailed error reports in the metadata.

Use Cases:

  • Verifying API request bodies.
  • Ensuring mandatory fields exist before database insertion.
  • Validating configuration parameters.

How it works

  1. Resolves the config. schema can be an object or a JSON string (as the code editor saves it); a string is parsed.
  2. Fails when the schema is missing or not an object.
  3. Compiles the schema on every run with Ajv (allErrors: true, strict mode on, draft-07 by default).
  4. Valid: the payload leaves through valid.
  5. Invalid: the payload leaves through invalid and every Ajv error is listed in meta.validation_errors.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-validate-payment",
  "label": "Validate payment",
  "operator_slug": "data.validate",
  "operator_version": "1.0.0",
  "config": {
    "schema": {
      "type": "object",
      "required": [
        "id",
        "amount"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "amount": {
          "type": "number",
          "minimum": 0
        }
      }
    }
  }
}

Configuration

schema object Required

The schema object to validate against.

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

schema
String values inside the schema containing {{ }} are resolved by the Expression Engine before compiling.

Output ports

valid default

The payload matches the schema.

Data
{
  "id": "pay_88",
  "amount": 120.5
}
invalid

The payload violates the schema. data is the unchanged payload.

Data
{
  "id": "pay_88",
  "amount": "120.5"
}
error

The schema is missing, is not valid JSON or does not compile.

Data
{
  "ok": false,
  "errors": [
    "Validation Error: strict mode: unknown keyword: \"required_fields\""
  ],
  "port": "error"
}

In expressions

What a later node can read from this node's output with $("Validate Data").item.json.<path> (write your node's label instead of Validate Data). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through valid, from the output shown in Ports.

ExpressionEditorWorker
$("Validate Data").item.json.payloadobjectThe worker does not return it: reads as undefined —
$("Validate Data").item.json.idstringNot suggested by the editor= "pay_88"—
$("Validate Data").item.json.amountnumberNot suggested by the editor= 120.5—

— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
Schema is not valid JSON: <message> error schema is a string that is not valid JSON.
Schema definition is required and must be an object error schema is missing or resolved to a non-object.
Validation Error: strict mode: unknown keyword: "<keyword>" error The schema uses a keyword Ajv does not know. Strict mode rejects it at compile time.
Validation Error: unknown format "<format>" ignored in schema at path "<path>" error format (email, date-time, uri...) needs ajv-formats, which is not loaded, so any format fails compilation. Use pattern instead.

Input contract

payload object Optional

Output contract

payload object Optional

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "data.validate",
  "name": "Validate Data",
  "category": "data",
  "version": "1.0.0",
  "description": "Validates the input payload against a JSON Schema (Draft-07).\n\n  Ensures data quality and integrity by strictly enforcing structure, types, and constraints before proceeding in the workflow. If validation fails, execution is routed to the 'invalid' port with detailed error metadata.\n\n  **Features:**\n  - Uses AJV (Another JSON Validator) under the hood.\n  - Supports full JSON Schema specification.\n  - Provides detailed error reports in the metadata.\n\n  **Use Cases:**\n  - Verifying API request bodies.\n  - Ensuring mandatory fields exist before database insertion.\n  - Validating configuration parameters.",
  "capabilities": [
    "validation",
    "schema",
    "json",
    "quality"
  ],
  "config_schema": {
    "type": "object",
    "required": [
      "schema"
    ],
    "properties": {
      "schema": {
        "type": "object",
        "title": "JSON Schema",
        "description": "The schema object to validate against.",
        "ui_widget": "code_editor",
        "ui_options": {
          "language": "json"
        }
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "description": "The payload to validate.",
    "properties": {
      "payload": {
        "type": "object"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "description": "The original payload (if valid).",
    "properties": {
      "payload": {
        "type": "object"
      }
    }
  },
  "ports": [
    {
      "port_id": "valid",
      "label": "Valid",
      "is_default": true,
      "description": "Data conforms to schema."
    },
    {
      "port_id": "invalid",
      "label": "Invalid",
      "description": "Data violates matches schema."
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Schema compilation or system error."
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "validation",
    "quality",
    "schema"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
No
Retries (retryOnFail)
No
Capabilities
validationschemajsonquality
Tags
validationqualityschema

Notes and limits

  • meta is recorded in the run steps only: downstream nodes receive data as their payload and cannot read meta through $json or $("Node").
  • invalid is not an error: the envelope has ok: true. Connect invalid to the branch that handles rejected data.
  • When the envelope has no data (or data is falsy), the engine stores the whole envelope as the node output: on error the next node receives { ok: false, errors: [...], port: "error" } as its payload.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs