Description
The ValidateJSON service validates a JSON document against a supplied JSON Schema.
The service is schema-only and environment-agnostic: it does not resolve schema references from nodes or other system resources. Both the JSON instance to be validated and the schema are supplied explicitly as JSON.
This service is intended to be used as a low-level capability. Higher-level services (for example, agent or node-aware services) are expected to resolve schemas, extract the relevant JSON fragment, and invoke this service to perform validation.
It supports:
- Validation of arbitrary JSON values
- Multiple JSON Schema drafts (detected from the
$schemaproperty when present) - Structured validation error reporting
Input
<ValidateJSON>
<data>
{
"schema": { ... JSON Schema ... },
"instance": { ... JSON value to validate ... }
}
</data>
</ValidateJSON>The <data> element must contain a JSON object with the following properties:
- schema – A JSON Schema object.
- instance – The JSON value to validate. This may be any valid JSON value, including
null.
The schema may declare its draft version using the $schema property. If no version is declared, the service defaults to a standard draft.
The service expects valid JSON input. Non-JSON constructs (such as functions or host objects) are not supported.
Output
<ValidateJSON>
<errorNumber>0</errorNumber>
<return>
{
"valid": true|false,
"errors": [
{
"path": "...",
"message": "...",
"code": "..."
}
]
}
</return>
</ValidateJSON>The valid flag indicates whether the JSON value conforms to the supplied schema.
The errors array contains zero or more validation errors. Each error includes:
- path – The JSON path (or pointer-like path) to the failing value.
- message – A human-readable description of the validation failure.
- code – A schema-specific error type or keyword, where available.
Errors
0 – Success (returning a non-valid result is considered a success).
103 – Parameter error (missing or invalid input)
100 – Other error