Overview
This node validates input data against a user-defined schema expressed in YAML format. The YAML schema is parsed and converted into a validation schema using the Zod library, which supports rich and complex validation rules. The node processes each input item, validates the specified data field against the schema, and routes valid and invalid items to separate outputs.
Common scenarios:
- Ensuring incoming JSON or object data conforms to expected formats before further processing.
- Validating API responses or webhook payloads against strict schemas.
- Enforcing data integrity in workflows by catching invalid data early.
- Complex nested data validation with detailed error reporting.
Practical example:
You receive webhook data containing user information and want to ensure the email is valid, age is a positive integer, and an optional array of tags is present. You define a YAML schema describing these constraints, then use this node to validate each incoming item. Valid items continue downstream; invalid ones are separated for error handling or logging.
Properties
| Name | Meaning |
|---|---|
| YAML Schema | A required YAML string defining the validation schema using a structure compatible with Zod. This schema describes the expected shape, types, and constraints of the input data. |
| Input Data | The name of the input field in each item that contains the data to be validated (default: "data"). |
Output
The node has two outputs:
Valid (first output): Items where the input data passed validation. Each item's
jsoncontains the parsed and validated data according to the schema.Invalid (second output): Items where validation failed. Each item's
jsonincludes avalidationResultobject with:valid: alwaysfalseerrors: detailed formatted errors from Zodissues: raw issues array from Zod describing each validation problemmessage: human-readable summary of validation errors with paths and messages
No binary data output is produced by this node.
Dependencies
- Zod: Used for building and executing the validation schema.
- js-yaml: Parses the YAML schema string into a JavaScript object.
- Requires the node to be configured with a valid YAML schema string.
- No external API keys or services are needed.
Troubleshooting
- Missing YAML schema: If the YAML schema property is empty, the node throws an error indicating the schema is required.
- Invalid YAML syntax: Malformed YAML will cause parsing errors; ensure the YAML schema is correctly formatted.
- Unsupported schema types: The schema must include a
typeproperty for each element. Unsupported types will cause errors. - Schema configuration errors: Missing required properties like
itemsfor arrays orpropertiesfor objects will throw descriptive errors. - Validation errors: When input data does not conform, detailed error messages are provided in the second output for debugging.
- Regular expression errors: Invalid regex patterns in the schema may cause runtime errors during schema building.
To resolve issues:
- Validate your YAML schema syntax independently.
- Ensure all required schema fields are present.
- Use the error messages in the invalid output to adjust your schema or input data accordingly.
Links and References
Summary of execute() logic (for clarity)
- Reads all input items.
- Retrieves the YAML schema string and input data field name.
- Parses the YAML schema into a JS object.
- Converts the JS object schema into a Zod schema.
- Iterates over each input item:
- Extracts the data from the specified field.
- Attempts to parse/validate it with the Zod schema.
- On success, pushes the item to the valid output with parsed data.
- On failure, formats errors and pushes the item to the invalid output.
- Returns two arrays: valid items and invalid items.