fox-schema-multi-conditions

4-way Condition node for n8n (Yes, No, Unknown, Failure) with visual rule builders, value/status classification, and schema validation for flexible n8n templates.

Package Information

Released: this month
Downloads: 0 weekly / 0 monthly
Latest Version: 0.1.2
Author: Huy Phan

Documentation

n8n-nodes-fox-schema-multi-conditions

A flexible 4-way Condition node for n8n that routes items into Yes, No, Unknown, and Failure outputs — designed for robust n8n templates where binary If (true/false) isn't enough.

Package naming note: n8n requires community node npm packages to begin with n8n-nodes- (plural), so this package is named n8n-nodes-fox-schema-multi-conditions.

Why 4 Outputs?

n8n's built-in If node only supports two paths (true / false). Real workflows and reusable templates frequently encounter four distinct outcomes:

Output Index Output Name Typical Meaning
0 Yes Condition matched / positive / approved / valid
1 No Negative condition matched / rejected / denied / false
2 Unknown Missing field, null, undefined, "unknown" / "unknow", pending, or indeterminate
3 Failure Explicit error payload, runtime/type validation failure, HTTP 4xx/5xx, or evaluation exception

Modes

1. If (4-Way Single Condition) (ifFourWay — Default)

Works like n8n's built-in If node with a single Conditions builder, but automatically routes into 4 branches instead of 2:

  • Condition passes → Yes
  • Condition evaluates to false → No
  • Checked value is missing, null, undefined, empty, or an unknown token (unknown, unknow, n/a, pending, etc.) → Unknown
  • Checked value is an error / failure token or throws a strict type / expression error → Failure

Uses 3-valued Kleene logic (false AND unknown => No, true OR unknown => Yes, any evaluation failure => Failure).

2. Value / Status Classification (classify)

Zero-boilerplate routing from a single expression (e.g. ={{ $json.status }}) or JSON field path (e.g. data.decision):

  • Classifies booleans, numbers, empty/null/undefined values, error objects, optional HTTP status codes (2xx → Yes, 4xx/5xx → Failure), and customizable keyword lists for Yes, No, Unknown, and Failure.

3. Multi-Condition Rules (Switch-Style) (rules)

Uses n8n's native visual Filter condition builders for each branch:

  • Yes Conditions, No Conditions (optional), Unknown Conditions (optional), Failure Conditions (optional)
  • Configurable Evaluation Priority (default: Failure -> Unknown -> Yes -> No) and Unmatched Item Route (No, Unknown, or Failure).

4. Schema & Field Check (schema)

Validates required JSON fields and expected types (string, number, boolean, array, object, any) before optionally evaluating a Pass Conditions filter:

  • Missing/empty fields → Unknown (or Failure, configurable per rule)
  • Type mismatches → Failure (or Unknown, configurable per rule)
  • Valid schema + pass condition match → Yes
  • Valid schema + pass condition non-match → No

Shared Options & Dynamic Output Labels

  • Output Labels — rename any of the 4 output connectors (Yes, No, Unknown, Failure) to match your template (for example Approved, Rejected, Pending, Error). The canvas port names and metadata labels update dynamically.
  • Route Evaluation Errors to Failure (default: true) — catches runtime expression or strict type errors per item and routes them to Failure instead of crashing the workflow.
  • Unknown / Failure Keywords (If 4-Way) — customize which string values automatically route to Unknown or Failure in If (4-Way) mode.
  • Treat Error Field as Failure (default: false) — checks $json.error (or custom dot-path) first.
  • Include Evaluation Metadata (default: false) — attaches _condition: { branch, label, mode, reason, matchedRule, error } without mutating upstream data.

Development & Local Testing

pnpm install
pnpm build
pnpm test
pnpm validate:n8n
pnpm scan:n8n

Trusted Publishing (OIDC)

This repository includes .github/workflows/publish.yml configured for npm OIDC Trusted Publishing (no NPM_TOKEN secret required).

In npm package settings (https://www.npmjs.com/package/n8n-nodes-fox-schema-multi-conditions/access), add a Trusted Publisher -> GitHub Actions entry:

  • Organization or user: tedious-code
  • Repository: n8n-nodes-fox-schema-multi-conditions
  • Workflow filename: publish.yml
  • Environment name: (leave blank)

Then push a version tag (e.g. git tag v0.1.1 && git push origin v0.1.1), publish a GitHub Release, or run Actions -> Publish to npm -> Run workflow.

Discussion