Skip to content
Data & Databases

Per-Route Conditional Field Contract Gate Before Append

9 nodes 10 1 Manual trigger
Download

Loading workflow…

Workflow Description

A fully local workflow that enforces a declared field contract inside each route before reports are appended. Manual Trigger plus a Code node emit eight fictional items for two routes (payments, logs); Set tags a stable routeId. A Code node validates every item only against its own route contract: always-required fields with accepted types plus conditional if-then rules (kind=transaction requires numeric amount, status=failed requires string errorCode). Results distinguish missing property, present-but-null and wrong type, and produce one summary per route with counts and per-rule compliance rates. If routes decisions, Set stamps them, Merge appends, and a final Code node emits one consolidated summary.

How it works

  1. 1.Manual Trigger starts the demo run.
  2. 2.Code emits 8 fictional route items, or passes through real items when provided.
  3. 3.Set adds a stable routeId with includeOtherFields enabled.
  4. 4.Code groups items by routeName and applies each route's own contract in isolation.
  5. 5.Per rule it counts applicable and compliant items, computes a compliance rate and records violations with recordId and issue type.
  6. 6.If sends passed=true route summaries to the accepted branch, others to the rejected branch.
  7. 7.Set in each branch adds a decision field while keeping the full report.
  8. 8.Merge in append mode concatenates both branches without unifying schemas.
  9. 9.Final Code node (runOnceForAllItems) returns exactly one consolidated summary item.

Use cases

  • Guarantee each branch satisfies its mandatory and conditional fields before merging
  • Validate transaction data where amount is required only for a specific kind
  • Validate log data where errorCode is required only on failure
  • Produce a field-quality report separating absence, null and type mismatch

Requirements

  • n8n 2.49.x with core nodes only (no credentials)
  • A stable routeName present on every item before validation
  • Contract definitions maintained inside the Validate Per-Route Contracts node
  • A recordId on each item so violations map back to their source

Setup and testing in n8n

  1. Import the JSON and open the workflow.
  2. Click Execute Workflow and inspect Build Final Gate Summary output.
  3. Confirm logs is accepted and payments is rejected due to PMT-002 (missing_field) and PMT-003 (wrong_type).
  4. Confirm PMT-005 (amount null with kind=fee) and LOG-003 (errorCode null with status=success) are not penalized because the antecedent is false.
  5. Make the emitter return an empty array and verify the 'empty input' report.
  6. Add an item with an unknown routeName and verify the missing_contract report.

Service Value

Ready-made workflow template for automation delivery and service execution.

Apps Used

Manual Trigger Code Set If Merge

Details

Trigger Manual trigger
Nodes 9
Apps 5
Views 10
Downloads 1

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (9)

/

Stage 1 - Demo Data & Setup

Sticky Note

#1

Stage 2 - Contract Gate

Sticky Note

#2

Stage 3 - Routing & Append

Sticky Note

#3

Run Contract Gate Demo

Manual Trigger

#4

Emit Fictional Route Items

Code

#5

Tag Route Identity

Set

#6

Validate Per-Route Contracts

Code

#7

Route Consensus Reached?

If

#8

Mark Route Accepted

Set

#9

Mark Route Rejected

Set

#10

Append Route Reports

Merge

#11

Build Final Gate Summary

Code

#12
Stay in the loop

Fresh workflows, straight to your inbox

Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.

  • New workflows
  • Clear overviews
  • Setup guides

Be first to discover what is new

Your name, your email, and one confirmation.

Email confirmation · Unsubscribe anytime