Package Information
Available Nodes
Documentation generating…
Documentation
@datafix/n8n-nodes-validator
This is an n8n community node. It lets you use validate items against a JSON schema in your n8n workflows.
How to use
The node takes 2 inputs:
- The data to be validated
- The JSON schema against which to validate the data
The node will output the validation result, which includes whether the data is valid or not, and any validation errors if applicable. If the data is valid, the node will also output the validated data. If the data is invalid, the node will output the validation errors via a separate output.
Per key that you want to validate, the following properties can be set:
| Field | Description | Required | Type |
|---|---|---|---|
field |
The key in the input data to validate. | Yes | string |
type |
The expected type of the value. Can be string, number, boolean, date, time, or datetime. |
Yes | string |
required |
Whether the field must exist in the input data. | Yes | boolean |
maxStringLength |
For string fields, the maximum number of characters allowed. For number fields, the maximum number of digits allowed before the decimal point. If omitted, the node's Default Max String Length is used. Use -1 for no limit. |
No | integer |
maxDecimal |
The maximum number of digits allowed after the decimal point for a number field. If omitted, the node's Default Max Decimal Places is used. Use -1 for no limit. |
No | number |
validTrueBooleans |
An array of values that should be treated as valid true values for a boolean field. If omitted, the node's configured Valid True Values are used. |
No | array |
validFalseBooleans |
An array of values that should be treated as valid false values for a boolean field. If omitted, the node's configured Valid False Values are used. |
No | array |
dateFormat |
The expected Luxon format for a date field, for example yyyy-MM-dd. Required when type is date. |
Conditional | string |
timeFormat |
The expected Luxon format for a time field, for example HH:mm:ss. Required when type is time. |
Conditional | string |
dateTimeFormat |
The expected Luxon format for a datetime field, for example yyyy-MM-dd HH:mm:ss ZZ. Required when type is datetime. |
Conditional | string |
timezone |
The IANA timezone to use for date, time, or datetime fields, for example Europe/Berlin or America/New_York. If omitted, UTC is used. |
No | string |
Configuration Options
Missing Fields
Adds fields to an item when they are missing from the input data but are defined in the schema.
The configured default value for each type is shared by all missing fields of that type. For example, if two missing fields both have type date, they will both receive the same configured default date value. You cannot configure separate default values per field here.
- Add Missing Fields > Adds fields that are defined in the schema but missing from the input data.
- Required Fields Only > When enabled, only missing fields marked as
requiredin the schema are added. - Default Value for String Fields > The value used when adding a missing
stringfield. - Default Value for Number Fields > The value used when adding a missing
numberfield. - Default Value for Boolean Fields > The value used when adding a missing
booleanfield. - Default Value for Date Fields > The value used when adding a missing
datefield. The value must match thedateFormatdefined for that field in the schema. - Default Value for Time Fields > The value used when adding a missing
timefield. The value must match thetimeFormatdefined for that field in the schema. - Default Value for DateTime Fields > The value used when adding a missing
datetimefield. The value must match thedateTimeFormatdefined for that field in the schema.
Missing fields are added before conversion options are applied. This means newly added values can also be converted or adjusted by the options below.
Conversion
Applies automatic transformations to values before final validation. This can be used to normalize types, trim keys, limit lengths or decimals, and convert date, time, datetime, and boolean values.
- Auto Trim Keys > Removes leading and trailing whitespace from field names. For example,
" name "becomes"name". - Convert Types > Attempts to convert values to the type defined in the schema. For example,
"123"can be converted to123when the field type isnumber. - Apply Max Decimal Places > Reduces the number of digits after the decimal point to the field's configured
maxDecimalvalue. - Apply Max String Length > For
stringfields, limits the number of characters tomaxStringLength. Fornumberfields, limits the number of digits before the decimal point. - Convert Boolean Values > Converts values recognized as valid true or false values into the configured output values.
- Converted True Value > The value used when converting a recognized true value.
- Converted False Value > The value used when converting a recognized false value.
- Convert Date Values > Parses date values using the field's
dateFormatand converts them to the configured output format. - Converted Date Format > The output format used when converting date values. For example,
dd-MM-yyyy. - Convert Time Values > Parses time values using the field's
timeFormatand converts them to the configured output format. - Converted Time Format > The output format used when converting time values. For example,
HH:mm. - Convert DateTime Values > Parses datetime values using the field's
dateTimeFormat, applies the configured timezone where applicable, and converts them to the configured output format. - Converted DateTime Format > The output format used when converting datetime values. For example,
yyyy-MM-dd HH:mm:ss ZZ.
Conversion options are applied after missing fields have been added and before the final validation of the item.
Options
Controls general validation behavior and output settings that are not specific to missing-field handling or value conversion.
- Error Output Field Name > Sets the field name used to store validation errors on invalid items. The default is
errors. - Default Timezone > Sets the timezone used for date, time, and datetime values when no
timezoneis specified directly in the schema. A timezone defined in the schema takes precedence over this setting.
Example
For example, suppose you want to validate product data containing a name, price, quantity, and active status.
Schema
The schema defines the validation rules for each field:
[
{
"field": "name",
"type": "string",
"required": true,
"maxStringLength": 100
},
{
"field": "price",
"type": "number",
"required": true,
"maxDecimal": 2
},
{
"field": "quantity",
"type": "number",
"required": false,
"maxDecimal": 0
},
{
"field": "active",
"type": "boolean",
"required": true,
"validTrueBooleans": [true, "true", "yes", 1],
"validFalseBooleans": [false, "false", "no", 0]
}
]
Matching data
The following items satisfy the schema:
[
{
"name": "Wireless Mouse",
"price": 29.95,
"quantity": 10,
"active": true
},
{
"name": "Mechanical Keyboard",
"price": 89.99,
"quantity": 5,
"active": "yes"
},
{
"name": "USB-C Cable",
"price": 12.5,
"active": 1
}
]
In this example:
nameis required and may contain at most 100 characters.priceis required and may contain at most 2 decimal places.quantityis optional and must be a whole number becausemaxDecimalis set to0.activeis required and accepts multiple representations of boolean values. For example,true,"yes", and1are all treated astrue.
n8n is a fair-code licensed workflow automation platform.