Skip to content

Data Validator

This module checks the input data against a schema you define and returns a validation report. It can optionally clean fields (trim spaces, strip HTML, lower-case…) before validating them, so the next node receives already normalized data.

It accepts an object or a list of objects. For lists it validates each element and reports paths such as data[0].field.

By default the module does not stop the flow when there are errors: it returns the data together with validation, and a later decision node can branch on validation.success. If you prefer the run to stop with an error, turn on Stop the flow on failure.

ParameterTypeRequiredDescription
schemajsonYesSchema with the rules of each field (see below). It can be written as an object or as JSON text
pathtextNoPath to the object or list to validate, for example data (a form’s content). Empty = all the previous node’s data
resultKeytextNoField of data where the result is added (default validation). With a list as input it is only added if you set it, and the list becomes items
stopOnErrorbooleanNoWhen on and anything is invalid, the run stops with an error summarizing the failures
errorMessagetextNoText that heads the error when the flow stops
RuleWhat it checks
requiredThe field exists and is not null
notEmptyA text that is not only spaces, or a list with items
typestring, number, boolean, object, array or null
enumThe value is in the allowed list
minLength / maxLengthMinimum / maximum length of a text
min / maxMinimum / maximum value of a number
formatemail, phone, url, date (YYYY-MM-DD, a real date), datetime, integer, uuid
patternRegular expression the text must match (optional patternFlags, for example i)
messageYour own message replacing that rule’s message
itemsSub-schema for each element of a list (type: "array")
cleanList of cleanups applied before validating (see below)

Empty texts in optional fields are not checked against length, format or pattern: use required or notEmpty to demand them.

Applied in the order given, and only to texts:

CleanupEffect
trimRemoves leading and trailing spaces
collapseTurns runs of spaces or line breaks into one and trims
stripHtmlRemoves HTML tags
lower / upperLower / upper case
cut:NCuts to N characters
{
"nextModule": "next-node",
"data": {
"email": "bad",
"validation": {
"success": false,
"errors": [
{ "field": "data.email", "message": "Invalid email format" },
{ "field": "data.phone", "message": "Field is required" }
],
"totalValidated": 1
}
}
}

The result goes inside data (data.validation), because that is what the next node receives: a decision node can use the condition data.validation.success === true. data is the input data (cleaned if the schema uses clean; the original object is never modified). Error messages are in English and include the full field path; use message to write them in your language.

With Stop the flow on failure and any error, the node ends with an error such as Invalid request — data.email: Invalid email format; data.phone: Field is required (it shows the first 5 failures).

Contact form: clean and require what matters

Section titled “Contact form: clean and require what matters”
{
"label": "Validate request",
"stopOnError": true,
"errorMessage": "Invalid request",
"schema": {
"name": { "required": true, "notEmpty": true, "clean": ["stripHtml", "collapse", "cut:120"] },
"email": { "required": true, "format": "email", "clean": ["trim", "lower"], "message": "Enter a valid email" },
"phone": { "format": "phone", "clean": ["collapse", "cut:40"] },
"reason": { "maxLength": 500, "clean": ["stripHtml", "collapse", "cut:500"] }
}
}

After a Webhook or a Form Trigger, the received fields are already at the top level of the data: leave the path empty. You only need to set it (for example data) when the caller sends the fields inside another object, such as { "data": { "email": "…" } }.

{
"label": "Check orders",
"schema": {
"reference": { "required": true, "pattern": "^[A-Z]{2}-\\d{3,}$" },
"total": { "required": true, "type": "number", "min": 0 },
"status": { "enum": ["new", "paid", "shipped"] },
"lines": { "type": "array", "notEmpty": true, "items": { "sku": { "required": true }, "quantity": { "type": "number", "min": 1 } } }
}
}
  • The module never modifies the input object: with clean it returns a cleaned copy.
  • Validation is recursive for array fields with items, and clean is also applied inside items.
  • validation.success is true only when there are no errors; totalValidated tells how many objects were validated.
  • An invalid pattern or an unknown format does not break the flow: it shows up as a validation error on that field.
  • A decision node after this module is recommended to branch on validation.success, unless you use Stop the flow on failure.
  • decision (Decision node - to act on the validation result)
  • multiroute (Multiroute - to branch the flow)
  • editFields (Edit Fields - to shape the already validated data)