Actions2
Overview
This node provides utility functions, with a focus here on validating input data against a user-defined JSON schema. It is useful when you want to ensure that incoming data conforms to a specific structure before further processing in your workflow. For example, you might use it to validate API responses, form inputs, or any JSON data to prevent errors downstream.
In the "Validate Against Schema" operation, the node takes each input item and checks if its JSON content matches the provided JSON schema. If the data does not conform, the node throws an error, stopping execution and indicating the validation issues.
Properties
| Name | Meaning |
|---|---|
| Input Schema | A JSON schema defining the expected structure of the input data. The node validates each input item against this schema. |
The Input Schema property expects a JSON object describing the schema, for example:
{
"type": "object",
"properties": {
"state": {
"type": "string"
},
"cities": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
Output
- The output contains the original input items that successfully passed the schema validation.
- Each output item retains its original JSON data.
- If any input item fails validation, the node throws an error and stops execution; no partial output is returned.
- This node does not produce binary data.
Dependencies
- Uses the
ajvlibrary internally for JSON schema validation. - No external API keys or services are required.
- No special environment variables or n8n credentials are needed.
Troubleshooting
- Common issue: Input data does not match the schema.
- Error message:
Input data does not match schema: <validation errors> - Resolution: Review the provided JSON schema and ensure the input data structure matches it exactly. Use tools like JSON schema validators to test your schema independently.
- Error message:
- Parsing errors: If the
Input SchemaJSON is malformed, the node will throw a parsing error.- Resolution: Ensure the JSON schema is valid JSON.
- Empty input: If no input items are provided, the node outputs an empty array without error.