JSON Schema Validation
Validate JSON against a JSON Schema and get each error with its path and message.
Pay by wallet (x402)
json-schema-validate Example
Example answer
{
"valid": true,
"errors": [],
"error_count": 0
} Inputs
| Field | Type | Required | What it is |
|---|---|---|---|
data | any | Yes | JSON data to validate |
schema | object | Yes | JSON Schema to validate against |
Output fields
How reliably each field appears in a successful answer.
| Field | Type | Appears |
|---|---|---|
valid | boolean | Always (present in every successful answer) |
errors | array | Always (present in every successful answer) |
error_count | integer | Always (present in every successful answer) |
How to call it
The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.
# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
-H "Authorization: Bearer $STRALE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"capability_slug": "json-schema-validate",
"inputs": {
"data": {
"age": 30,
"name": "Alice"
},
"schema": {
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
},
"max_price_cents": 2
}' {
"tool": "strale_execute",
"arguments": {
"slug": "json-schema-validate",
"inputs": {
"data": {
"age": 30,
"name": "Alice"
},
"schema": {
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
},
"max_price_cents": 2
}
} import { Strale } from "straleio";
const strale = new Strale({ apiKey: process.env.STRALE_API_KEY! });
const result = await strale.do({
capability_slug: "json-schema-validate",
inputs: {
"data": {
"age": 30,
"name": "Alice"
},
"schema": {
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
},
max_price_cents: 2,
}); import os
from straleio import Strale, DoRequest
strale = Strale(api_key=os.environ["STRALE_API_KEY"])
result = strale.do(DoRequest(
capability_slug="json-schema-validate",
inputs={
"data": {
"age": 30,
"name": "Alice",
},
"schema": {
"type": "object",
"properties": {
"age": {
"type": "integer",
},
"name": {
"type": "string",
},
},
},
},
max_price_cents=2,
)) # No account. The first request answers 402 with the price in USDC;
# an x402 client pays it from your wallet and repeats the request.
curl -i -X POST https://api.strale.io/x402/v2/json-schema-validate \
-H 'Content-Type: application/json' \
-d '{
"data": {
"age": 30,
"name": "Alice"
},
"schema": {
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
}' Limitations
Only JSON Schema Draft-07 is supported
Validates against JSON Schema Draft-07 — newer drafts (2019-09, 2020-12) may have features not fully supported
What to do instead: Specify your target draft version and test edge cases with draft-specific keywords like $dynamicRef
Related tools
- JSON Diff €0.03