Schema Validation

v1.0.0
Validation
objectarraystringreversible

Description

Schema Validation

Validate JSON against a JSON Schema-style subset and return a field-level report.

This utility is a report-producing transformer. It does not block, skip, warn, or otherwise control pipeline execution. Use validation.contract when a pipeline needs guardrail behavior.

Supported V1 Schema Fields

  • type: object, array, string, number, boolean, or null
  • required: array of required object keys
  • properties: object field rules
  • items: array item rule
  • enum: primitive values only, using strings, numbers, booleans, or null

Unknown fields are ignored in V1.

Invalid schema config returns:

{
  "valid": false,
  "errors": [
    { "field": "$schema", "message": "Missing or invalid schema config" }
  ]
}

Configuration

NameTypeDefaultDescription
Schema Configjson{"type":"object","required":[],"properties":{}}JSON Schema-style subset. Supports type, required, properties, items, and primitive enum values. Unknown fields are ignored in V1.

Examples

AI Prompt
Validate this order payload against a small schema config.
Input
1{
2 "order_id": "ORD_1001",
3 "customer_email": null,
4 "total_amount": "42.50",
5 "currency": "USD",
6 "items": 2
7}
Config
Schema Config
1{
2 "type": "object",
3 "required": [
4 "order_id",
5 "customer_email",
6 "total_amount",
7 "currency",
8 "items"
9 ],
10 "properties": {
11 "order_id": {
12 "type": "string"
13 },
14 "customer_email": {
15 "type": "string"
16 },
17 "total_amount": {
18 "type": "number"
19 },
20 "currency": {
21 "type": "string",
22 "enum": [
23 "USD",
24 "EUR",
25 "GBP"
26 ]
27 },
28 "items": {
29 "type": "array",
30 "items": {
31 "type": "object",
32 "required": [
33 "sku",
34 "qty"
35 ],
36 "properties": {
37 "sku": {
38 "type": "string"
39 },
40 "qty": {
41 "type": "number"
42 }
43 }
44 }
45 }
46 }
47}
Output
1{
2 "valid": false,
3 "errors": [
4 {
5 "field": "customer_email",
6 "message": "Expected string, received null"
7 },
8 {
9 "field": "total_amount",
10 "message": "Expected number, received string"
11 },
12 {
13 "field": "items",
14 "message": "Expected array, received number"
15 }
16 ]
17}

API Usage

POST /api/v1/utilities/validation.schema
Example:
curl -X POST https://your-domain.com/api/v1/utilities/validation.schema \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs":{"primary":{"order_id":"ORD_1001","customer_email":null,"total_amount":"42.50","currency":"USD","items":2}},"config":{"schema":{"type":"object","required":["order_id","customer_email","total_amount","currency","items"],"properties":{"order_id":{"type":"string"},"customer_email":{"type":"string"},"total_amount":{"type":"number"},"currency":{"type":"string","enum":["USD","EUR","GBP"]},"items":{"type":"array","items":{"type":"object","required":["sku","qty"],"properties":{"sku":{"type":"string"},"qty":{"type":"number"}}}}}}}}'
Response
1{
2 "valid": false,
3 "errors": [
4 {
5 "field": "customer_email",
6 "message": "Expected string, received null"
7 },
8 {
9 "field": "total_amount",
10 "message": "Expected number, received string"
11 },
12 {
13 "field": "items",
14 "message": "Expected array, received number"
15 }
16 ]
17}