Data Validator
Description
Section titled “Description”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.
Configuration
Section titled “Configuration”| Parameter | Type | Required | Description |
|---|---|---|---|
| schema | json | Yes | Schema with the rules of each field (see below). It can be written as an object or as JSON text |
| path | text | No | Path to the object or list to validate, for example data (a form’s content). Empty = all the previous node’s data |
| resultKey | text | No | Field 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 |
| stopOnError | boolean | No | When on and anything is invalid, the run stops with an error summarizing the failures |
| errorMessage | text | No | Text that heads the error when the flow stops |
Rules for each field
Section titled “Rules for each field”| Rule | What it checks |
|---|---|
required | The field exists and is not null |
notEmpty | A text that is not only spaces, or a list with items |
type | string, number, boolean, object, array or null |
enum | The value is in the allowed list |
minLength / maxLength | Minimum / maximum length of a text |
min / max | Minimum / maximum value of a number |
format | email, phone, url, date (YYYY-MM-DD, a real date), datetime, integer, uuid |
pattern | Regular expression the text must match (optional patternFlags, for example i) |
message | Your own message replacing that rule’s message |
items | Sub-schema for each element of a list (type: "array") |
clean | List 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.
Cleanups (clean)
Section titled “Cleanups (clean)”Applied in the order given, and only to texts:
| Cleanup | Effect |
|---|---|
trim | Removes leading and trailing spaces |
collapse | Turns runs of spaces or line breaks into one and trims |
stripHtml | Removes HTML tags |
lower / upper | Lower / upper case |
cut:N | Cuts to N characters |
Output
Section titled “Output”{ "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).
Usage Examples
Section titled “Usage Examples”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": "…" } }.
Order list with required fields
Section titled “Order list with required fields”{ "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
cleanit returns a cleaned copy. - Validation is recursive for
arrayfields withitems, andcleanis also applied insideitems. validation.successistrueonly when there are no errors;totalValidatedtells how many objects were validated.- An invalid
patternor 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.
Related Nodes
Section titled “Related Nodes”- decision (Decision node - to act on the validation result)
- multiroute (Multiroute - to branch the flow)
- editFields (Edit Fields - to shape the already validated data)