Data Validator
Description
Section titled “Description”This module validates input data against a defined schema. It is a synchronous (non-async) module that evaluates each data field according to the configured rules and returns a validation report without modifying the original data.
Validation capabilities:
- Required fields (
required): Verifies that the field exists and is not null or undefined. - Type validation (
type): Checks that the value is of the expected type. Supported types: string, number, boolean, object, array, null. - Allowed values (
enum): Verifies that the value is within a list of allowed values. - Recursive subarray validation (
items): If a field is of type array and hasitemsdefined, validates each array element against the sub-schema.
The module supports both individual objects and arrays of objects. For arrays, it validates each element individually and reports errors with paths like data[0].field.
Important: the module does not stop the flow if there are validation errors. It always returns the original data along with the validation result, allowing the next node to decide how to handle the errors.
Configuration
Section titled “Configuration”| Parameter | Type | Required | Description |
|---|---|---|---|
| schema | object | Yes | Validation schema with rules per field. Each field can have: required, type, enum, items. |
Output
Section titled “Output”{ "nextModule": "siguiente-nodo", "data": { }, "validation": { "success": true, "errors": [], "totalValidated": 1 }}Output with errors
Section titled “Output with errors”{ "nextModule": "siguiente-nodo", "data": { }, "validation": { "success": false, "errors": [ { "field": "data.email", "message": "Field is required" }, { "field": "data.age", "message": "Expected type number, got string" }, { "field": "data.status", "message": "Invalid value 'unknown', must be one of: active, inactive" } ], "totalValidated": 1 }}Usage Example
Section titled “Usage Example”Basic case
Section titled “Basic case”{ "schema": { "nombre": { "required": true, "type": "string" }, "edad": { "required": true, "type": "number" }, "email": { "required": true, "type": "string" }, "estado": { "type": "string", "enum": ["activo", "inactivo", "pendiente"] }, "direcciones": { "type": "array", "items": { "calle": { "required": true, "type": "string" }, "ciudad": { "required": true, "type": "string" } } } }}- The module does not modify the input data; it always returns them as-is in the
datafield. - Validation is recursive for array-type fields with
items. - Error messages are in English and include the full field path (e.g.:
data[0].direcciones[1].calle). - The
validation.successfield istrueonly if there are no errors. totalValidatedindicates how many objects were validated (useful when the input is an array).- It is recommended to use a decision node after this module to branch the flow based on
validation.success. - This module is synchronous and does not require credentials or access to external APIs.
Related Nodes
Section titled “Related Nodes”- decision (Decision node - to act based on validation result)
- multiroute (Multiroute - to branch flow)