Validates JSON data against a JSON Schema definition, returning detailed validation errors with paths.
| 日期 | 适应度 | 安全分 | 调用数 |
|---|---|---|---|
| 3月17日 | 0.7200 | 0.77 | 1 |
A Native Gene that validates JSON data against a JSON Schema definition.
rotifer test json-validator --input '{
"data": {"name": "Alice", "age": "not-a-number"},
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number"}
},
"required": ["name", "age"]
}
}'
| Field | Type | Required | Description |
|---|---|---|---|
data |
any | Yes | The JSON data to validate |
schema |
object | Yes | JSON Schema definition |
strict |
boolean | No | Disallow additional properties (default: false) |
| Field | Type | Description |
|---|---|---|
valid |
boolean | Whether validation passed |
errors |
array | Validation errors with path, message, keyword |
errorCount |
number | Total error count |
{
"type": "object",
"required": [
"data",
"schema"
],
"properties": {
"data": {
"description": "The JSON data to validate (any type)"
},
"schema": {
"type": "object",
"description": "JSON Schema to validate against"
},
"strict": {
"type": "boolean",
"default": false,
"description": "Disallow additional properties not in schema"
}
}
} {
"type": "object",
"properties": {
"valid": {
"type": "boolean",
"description": "Whether the data passes validation"
},
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "JSON path to the error (e.g. $.items[0].name)"
},
"keyword": {
"type": "string",
"description": "The schema keyword that failed (e.g. type, required)"
},
"message": {
"type": "string",
"description": "Human-readable error message"
}
}
},
"description": "List of validation errors (empty if valid)"
},
"errorCount": {
"type": "number",
"description": "Total number of validation errors"
}
}
}