Description
n8n-nodes-input-validator
The n8n-nodes-input-validator validates and transforms input data in n8n against configurable criteria. It supports strings, numbers, booleans, dates, enums, and international phone numbers (via google-libphonenumber), with comprehensive options for validation strictness and error handling.
Install
- From n8n (Community Nodes): search for
n8n-nodes-input-validatorand install. - Or via npm in your community nodes container/directory:
npm install n8n-nodes-input-validator
Features
Supported String Formats
Common Formats: Email, URL, UUID, Alphanumeric, Alpha (letters only), Numeric, Integer, Phone number, Postal code, Credit card
Network & Technical: IP Address (IPv4/IPv6), IPv4 Address, IPv6 Address, IP Range (CIDR), MAC Address, Port, FQDN, MIME Type
Data Formats: JSON, JWT, Base64, Hexadecimal, Hex Colour, Hash (MD5/SHA1/SHA256/SHA384/SHA512/etc.), MongoDB ObjectId
Web & URLs: URL, URL Slug, Mailto URI
Financial & Business: Currency, Credit Card, BIC/SWIFT, IBAN, VAT Number, Tax ID, Bitcoin Address, Ethereum Address
Date & Time: ISO 8601, RFC 3339, Time
Identifiers: ISBN (10/13), UUID (v3/v4/v5), Semantic Version
Coordinates: Latitude/Longitude
Security: Strong Password, Custom Regex Pattern
Usage
Node Configuration
The node operates in Output Items mode, validating data and outputting items with an isValid property and optional errors array.
#### Global Settings
isValid and errors properties (excludes item data)user.email). – Note: When both Remove Unspecified Fields and Omit Empty Fields are enabled, filtering happens first (keeping only specified fields), then empty field removal is applied to the filtered output.
– Continue: Pass through original data with validation errors included
– Set Invalid Fields to Empty: Set fields that fail validation to empty values (empty string, 0, false, etc.)
– Set Invalid Fields to Null: Set fields that fail validation to null
– Skip Field (default): Remove the field that failed validation but continue to output the item
– Skip Item: Exclude the item from output when validation fails
– Throw Error: Fail the entire item when any validation fails
#### Phone Rewrite Options (when enabled)
phoneRewrites summary array from outputField Configuration
Each validation field supports the following properties:
#### Common Properties (All Types)
string, number, boolean, date, or enum – Plain text = appends to standard message
– !text = replaces standard message
– ^text = prepends to standard message
#### String Validation
Format-Specific Options (collapsed by default):
#### Number Validation
– None: No additional constraints
– Minimum: Must be ≥ min value
– Maximum: Must be ≤ max value
– Range: Must be between min and max values
– One Of: Must match one of the specified values
#### Boolean Validation
#### Date Validation
#### Enum Validation
Example Configurations
#### Basic Email Validation
{
"Validation Name": "customerEmail",
"Validation Type": "string",
"String Data": "{{ $json.email }}",
"String Format": "email",
"Required": true,
"Custom Error Message": "Please provide a valid business email address"
}
#### Phone Validation with Rewrite
{
"Validation Name": "mobilePhone",
"Validation Type": "string",
"String Data": "{{ $json.phone }}",
"String Format": "Phone Number",
"Phone Region": "AU",
"Validation Mode": "Valid (Strict)",
"Expected Type(s)": ["MOBILE"],
"Enable Phone Rewrite": true,
"Output Field Name": "formattedMobile",
"Rewrite Format": "E.164"
}
#### Number Range Validation
{
"Validation Name": "quantity",
"Validation Type": "number",
"Number Data": "{{ $json.qty }}",
"Number Validation Type": "Range",
"Min Value": 1,
"Max Value": 100,
"Required": true,
"Custom Error Message": "^Quantity out of range."
}
#### Enum Validation
{
"Validation Name": "status",
"Validation Type": "enum",
"String Data": "{{ $json.status }}",
"Enum Values": "pending, approved, rejected",
"Required": true
}
Output Structure
By default, the node augments each item with validation results:
{
"originalField1": "value1",
"originalField2": "value2",
"isValid": true,
"errors": [
{
"field": "fieldName",
"message": "Error message"
}
]
}
Properties:
– field: Name of the field that failed validation
– message: Error message describing the validation failure
– resolved: (Optional) Boolean indicating if error was auto-resolved (e.g., phone realignment)
– resolution: (Optional) Description of how the error was resolved
With Output only isValid enabled:
{
"isValid": false,
"errors": [...]
}
(Original item data is excluded)
With Remove Unspecified Fields enabled:
{
"email": "user@example.com",
"quantity": 5,
"isValid": true
}
(Only fields specified in the validator inputs are included, plus isValid and errors. Other fields from the input are removed.)
For example, if your input item has:
{
"email": "user@example.com",
"quantity": 5,
"extrafield": "somevalue",
"anotherfield": "anothervalue"
}
And you only validate email and quantity, the output will only include those validated fields plus isValid (and errors if any).
Phone Validation & Rewriting
When String Format is set to Phone Number, the node uses google-libphonenumber for robust international phone validation and formatting.
#### Validation Options
– Valid (Strict): Full validity check (isValidNumber)
– Possible (Lenient): Possibility check only (isPossibleNumber)
– Valid For Region: Validity within specified region (isValidNumberForRegion)
– Possible For Type: Possibility check constrained to selected types
– FIXEDLINE, MOBILE, FIXEDLINEORMOBILE, TOLLFREE, PREMIUMRATE, SHAREDCOST, VOIP, PERSONALNUMBER, PAGER, UAN, VOICEMAIL, UNKNOWN
– Empty String
– Leave As Is
– Null
– Skip Field
– Throw Error (fail item)
– Use Global Setting (default)
#### Phone Rewrite/Formatting
Enable Enable Phone Rewrite at the node level, then enable Enable Phone Rewrite for individual phone fields.
Per-Field Rewrite Options:
Formatted ) – E.164: +61412345678 (recommended for databases/APIs)
– INTERNATIONAL: +61 412 345 678 (human-readable international)
– NATIONAL: 0412 345 678 (local format)
– RFC3966: tel:+61-412-345-678 (tel: URI scheme)
Advanced Rewrite Options (collapsed by default):
Global Rewrite Options:
phoneRewrites summary array (default: false)#### Phone Rewrite Output
When phone rewrite is enabled, the node adds formatted phone numbers to the item:
{
"name": "John Smith",
"mobile": "0412 345 678",
"mobileFormatted": "+61412345678",
"phoneRewrites": [
{
"name": "mobile",
"original": "0412 345 678",
"outputProperty": "mobileFormatted",
"formatted": "+61412345678",
"format": "E164",
"region": "AU",
"type": "MOBILE",
"valid": true,
"possible": true,
"expectedTypes": ["MOBILE"],
"expectedTypeMatch": true
}
],
"isValid": true
}
Auto-Realignment Example:
If two phone fields have mismatched types (e.g., mobile number in landline field), the node can automatically swap them:
{
"phoneRewrites": [
{
"name": "landline",
"correctionMade": true,
"correctionSource": "mobile",
"formatted": "+61383214567"
},
{
"name": "mobile",
"correctionMade": true,
"correctionSource": "landline",
"formatted": "+61412345678"
}
]
}
Advanced Features
Custom Error Messages
Use the Custom Error Message field on any validation field to provide context-specific error messages:
"This value is required for processing" – Output: "Invalid email address. This value is required for processing"
! prefix (replaces): "!Email must be from approved domain" – Output: "Email must be from approved domain"
^ prefix (prepends): "^Critical validation error:" – Output: "Critical validation error: Invalid email address."
Progressive Disclosure UI
The node uses a progressive disclosure pattern to reduce UI clutter:
⚙️ Advanced Options toggleNested Field Support
All validation fields support dot notation for nested object paths:
{
"Validation Name": "user.profile.email",
"String Data": "{{ $json.user.profile.email }}",
"String Format": "email"
}
The validated/rewritten value will be written back to the nested path in the output.
Development
Setup
1. Clone the repository:
git clone https://github.com/yourusername/n8n-nodes-input-validator.git
cd n8n-nodes-input-validator
2. Install dependencies:
npm install
3. Build the project:
npm run build
4. Link to n8n for local development:
npm link
cd ~/.n8n/nodes
npm link n8n-nodes-input-validator
Testing
The node includes comprehensive validation logic using:
Attribution
This project is a fork with substantial changes. Credit to the original author cdmx1 (https://github.com/cdmx1) for the initial concept and implementation.
License
Licensed under the Apache License, Version 2.0. See LICENSE for details. If you distribute modified versions, ensure you include appropriate attribution as required by Section 4 of the license.