validate_schema
Validate context data against a JSON Schema.
Parameters
- source_keystringrequired
- Top-level context key whose value will be validated
- schemaobject*
- A JSON Schema object to validate the data against
- schema_keystring*
- Context key containing a JSON Schema object or JSON Schema string
*Provide exactly one of schema or schema_key.
The node retrieves the value stored under source_key in the workflow context and validates it using the provided JSON Schema. If validation fails, the node returns an error and the workflow step is marked as failed.
Use this node when the value is already in your context as JSON (object/array/value).
If the context value is a raw JSON string, use json_validate instead.
Context Output
validation_success-- boolean indicating whether validation passedvalidation_errors-- array of error description strings (empty on success)
Note: When validation fails the node returns a structured error. Downstream
steps execute only if a dedicated on_error handler successfully resolves that
failure. After retries are exhausted, the final validation result is buffered
for the source phase barrier and the handler receives its source-exact copy in
_error_output. Normal shared keys still follow declaration-order collision
precedence if a parallel step publishes the same names.
Example
local flow = Flow.new("user_registration")
flow:step("validate", nodes.validate_schema({
source_key = "payload",
schema = {
type = "object",
required = { "email", "name" },
properties = {
email = { type = "string" },
name = { type = "string" },
age = { type = "integer", minimum = 0 }
}
}
}))
flow:step("done", nodes.log({
message = "Validation passed for ${ctx.payload.name} (${ctx.payload.email})"
})):depends_on("validate")
return flow
Validate with a schema loaded from context
local flow = Flow.new("validate_from_context")
flow:step("read_schema", nodes.read_file({
path = "schemas/user.schema.json",
output_key = "schema"
}))
flow:step("validate", nodes.validate_schema({
source_key = "payload",
schema_key = "schema_content"
})):depends_on("read_schema")
return flow