Skip to content

Data Validator

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:

  1. Required fields (required): Verifies that the field exists and is not null or undefined.
  2. Type validation (type): Checks that the value is of the expected type. Supported types: string, number, boolean, object, array, null.
  3. Allowed values (enum): Verifies that the value is within a list of allowed values.
  4. Recursive subarray validation (items): If a field is of type array and has items defined, 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.

ParameterTypeRequiredDescription
schemaobjectYesValidation schema with rules per field. Each field can have: required, type, enum, items.
{
"nextModule": "siguiente-nodo",
"data": { },
"validation": {
"success": true,
"errors": [],
"totalValidated": 1
}
}
{
"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
}
}
{
"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 data field.
  • 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.success field is true only if there are no errors.
  • totalValidated indicates 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.
  • decision (Decision node - to act based on validation result)
  • multiroute (Multiroute - to branch flow)