
Serialization ValidateJsonSchema
CertifiedValidate JSON data against a JSON Schema
Serialization ValidateJsonSchema
Validate JSON data against a JSON Schema
Validates a JSON payload against a JSON Schema, given inline or fetched from a Confluent-compatible Schema Registry such as Karapace.
The $schema keyword of the schema selects the draft; when it is absent, defaultDialect is used. Draft-04, draft-06 and draft-07 check format values. Draft 2019-09 and draft 2020-12, the default, treat format as an annotation and do not check it, as the specification requires; set $schema or defaultDialect to an earlier draft to enforce formats.
With draft-04 the validator mirrors java-json-tools/json-schema-validator: the same set of checked format values (date-time, email, hostname, ipv4, ipv6, regex, uri, uuid, json-pointer, uri-template, base64, md5, sha1, sha256, sha512, mac), ECMA-262 regular expressions, and unknown keywords ignored. Keywords that need custom validator code are therefore not enforced.
Remote $ref URLs are never fetched. The payload is read as a single JSON document; JSONL files are not validated record by record.
type: io.kestra.plugin.serdes.json.ValidateJsonSchemaExamples
Validate a payload against an inline JSON Schema and fail the task when it does not match.
id: validate_json_inline
namespace: company.team
inputs:
- id: payload
type: JSON
defaults: '{"id": 1, "email": "ada@example.com"}'
tasks:
- id: validate
type: io.kestra.plugin.serdes.json.ValidateJsonSchema
from: "{{ inputs.payload }}"
schema: |
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["id", "email"],
"properties": {
"id": {"type": "integer"},
"email": {"type": "string", "format": "email"}
}
}
Validate a stored file against a namespace file schema, using draft-04 when the schema has no $schema.
id: validate_json_namespace_file
namespace: company.team
tasks:
- id: download
type: io.kestra.plugin.core.http.Download
uri: https://example.com/data/orders.json
- id: validate
type: io.kestra.plugin.serdes.json.ValidateJsonSchema
from: "{{ outputs.download.uri }}"
schema: "{{ read('schemas/order.json') }}"
defaultDialect: DRAFT_4
Validate against a schema stored in a Karapace registry and branch on the result instead of failing.
id: validate_json_registry
namespace: company.team
tasks:
- id: fetch_order
type: io.kestra.plugin.core.http.Request
uri: https://example.com/api/orders/42
- id: validate
type: io.kestra.plugin.serdes.json.ValidateJsonSchema
from: "{{ outputs.fetch_order.body }}"
failOnInvalid: false
registry:
url: https://my-karapace.aivencloud.com:12345
subject: orders-value
subjectVersion: latest
options:
auth:
type: BASIC
username: "{{ secret('REGISTRY_USERNAME') }}"
password: "{{ secret('REGISTRY_PASSWORD') }}"
- id: if_invalid
type: io.kestra.plugin.core.flow.If
condition: "{{ outputs.validate.valid == false }}"
then:
- id: report
type: io.kestra.plugin.core.log.Log
message: "Invalid order: {{ outputs.validate.errors }}"
Properties
from *object
JSON data to validate
One of: a string containing JSON text, a kestra:// internal storage URI of a JSON file (read as UTF-8), or an object, array or scalar value, which is serialized to JSON before validation.
assets
Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.
io.kestra.core.models.assets.AssetsDeclaration
IGNOREFAILWARNAsset failure behavior
Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.
Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.
The assets consumed as inputs.
io.kestra.core.models.assets.AssetIdentifier
1The assets produced as outputs.
io.kestra.plugin.ee.assets.Dataset
1150{}1150io.kestra.plugin.ee.assets.File
1150{}1150io.kestra.plugin.ee.assets.Table
1150{}1150io.kestra.plugin.ee.assets.VM
1150{}1150io.kestra.core.models.assets.External
1150{}1150io.kestra.core.models.assets.Custom
11501Custom asset type
{}1150defaultDialect string
DRAFT_2020_12DRAFT_4DRAFT_6DRAFT_7DRAFT_2019_09DRAFT_2020_12Default dialect
Draft used when the schema has no $schema keyword. One of DRAFT_4, DRAFT_6, DRAFT_7, DRAFT_2019_09 or DRAFT_2020_12. Defaults to DRAFT_2020_12, where format is annotation-only as the specification requires; set DRAFT_4 to match java-json-tools/json-schema-validator, which checks formats.
failOnInvalid booleanstring
trueFail on invalid data
When true (default), the task fails if the data does not match the schema. When false, the task succeeds with valid: false and the list of errors.
registry
Schema Registry
Fetch the schema from a Confluent-compatible Schema Registry. Set exactly one of schema or registry.
Confluent-compatible Schema Registry
Fetches a JSON Schema from a Confluent-compatible Schema Registry such as Karapace. Set either subject (with an optional subjectVersion) or id. Only registered schemas of type JSON without references are supported.
Global schema ID
Registry-wide schema ID. Mutually exclusive with subject.
HTTP options
Authentication (basic or bearer), SSL, proxy and timeout settings used to call the registry.
io.kestra.core.http.client.configurations.HttpConfiguration
falseIf true, allow a failed response code (response code >= 400)
List of response code allowed for this request
The authentication to use.
io.kestra.core.http.client.configurations.BasicAuthConfiguration
The password for HTTP basic authentication.
The username for HTTP basic authentication.
io.kestra.core.http.client.configurations.BearerAuthConfiguration
The token for bearer token authentication.
io.kestra.core.http.client.configurations.DigestAuthConfiguration
The password for HTTP Digest authentication.
The username for HTTP Digest authentication.
UTF-8The default charset for the request.
java.nio.charset.Charset
trueWhether to enable TCP Keep-Alive extended socket options (TCP_KEEPIDLE, TCP_KEEPINTERVAL, TCP_KEEPCOUNT).
Set to false when running on Windows workers, as these extended socket options are not supported by the Windows JDK and will cause connection failures.
trueWhether redirects should be followed automatically.
REQUEST_HEADERSREQUEST_BODYRESPONSE_HEADERSRESPONSE_BODYThe enabled log.
The proxy configuration.
io.kestra.core.http.client.configurations.ProxyConfiguration
The address of the proxy server.
The password for proxy authentication.
The port of the proxy server.
DIRECTDIRECTHTTPSOCKSThe type of proxy to use.
The username for proxy authentication.
The SSL request options
io.kestra.core.http.client.configurations.SslOptions
Whether to disable checking of the remote SSL certificate.
Only applies if no trust store is configured. Note: This makes the SSL connection insecure and should only be used for testing. If you are using a self-signed certificate, set up a trust store instead.
The timeout configuration.
io.kestra.core.http.client.configurations.TimeoutConfiguration
The time allowed to establish a connection to the server before failing.
PT5MThe time allowed for a read connection to remain idle before closing it.
Subject
Subject holding the schema. Required unless id is set.
Subject version
Version of the subject: an integer or latest, which is the default. Ignored when id is set.
Registry URL
Base URL of the registry, for example https://my-registry.example.com: 12345. A path prefix is allowed.
schema string
Inline JSON Schema
The JSON Schema as text. Use {{ read('path/to/schema.json') }} to load a namespace file. Set exactly one of schema or registry.
Outputs
errors array
Validation errors
Empty when valid. Limited to the first 100 errors; the errors metric holds the total.
io.kestra.plugin.serdes.json.ValidateJsonSchema-ValidationError
JSON Pointer to the offending value in the data
Empty for the document root.
Schema keyword that failed
For example required or type.
Human-readable error message
Location of the failing keyword in the schema
schemaId integer
Registry schema ID
Only set when the schema came from a registry.
schemaVersion integer
Registry subject version
Only set when the schema came from a registry subject.
valid boolean
falseWhether the data matches the schema
Metrics
errors counter
Number of validation errors found