json_schema

Validates a message against the provided JSONSchema definition to retrieve a boolean response indicating whether the message matches the schema or not.

json_schema:
schema: ""
schema_path: ""

If the response is true the condition passes, otherwise it does not. Please refer to the JSON Schema website for information and tutorials regarding the syntax of the schema.

Fields

schema

string A schema to apply. Use either this or the schema_path field.

schema_path

string The path of a schema document to apply. Use either this or the schema field.

part

number The index of a message within a batch to test the condition against. This field is only applicable when batching messages at the input level.

Indexes can be negative, and if so the part will be selected from the end counting backwards starting from -1.

Examples

With the following JSONSchema document:

{
"$id": "https://example.com/person.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
}
}
}

And the following Benthos configuration:

json_schema:
schema_path: "file://path_to_schema.json"

If the message being processed looked like:

{"firstName":"John","lastName":"Doe","age":21}

Then the condition would pass.