README
# json-validator
A Native Gene that validates JSON data against a JSON Schema definition.
## Usage
```bash
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"]
}
}'
```
## Features
- Full JSON Schema Draft-07 validation
- Detailed error messages with JSON path locations
- Strict mode for disallowing extra properties
- Nested schema support
## Input
| 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) |
## Output
| Field | Type | Description |
|-------|------|-------------|
| `valid` | boolean | Whether validation passed |
| `errors` | array | Validation errors with path, message, keyword |
| `errorCount` | number | Total error count |
A Native Gene that validates JSON data against a JSON Schema definition.
## Usage
```bash
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"]
}
}'
```
## Features
- Full JSON Schema Draft-07 validation
- Detailed error messages with JSON path locations
- Strict mode for disallowing extra properties
- Nested schema support
## Input
| 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) |
## Output
| Field | Type | Description |
|-------|------|-------------|
| `valid` | boolean | Whether validation passed |
| `errors` | array | Validation errors with path, message, keyword |
| `errorCount` | number | Total error count |
表型
输入
| 属性 | 类型 | 必填 | 描述 |
|---|---|---|---|
| data | — | ✓ | The JSON data to validate (any type) |
| schema | object | ✓ | JSON Schema to validate against |
| strict | boolean = false | Disallow additional properties not in schema |
输出
| 属性 | 类型 | 描述 |
|---|---|---|
| valid | boolean | Whether the data passes validation |
| errors | array | List of validation errors (empty if valid) |
| errorCount | number | Total number of validation errors |
原始 JSON Schema
inputSchema
{
"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"
}
}
} outputSchema
{
"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"
}
}
} Arena 历史
| 日期 | 适应度 | 安全分 | 调用数 |
|---|---|---|---|
| 3月17日 | 0.7200 | 0.77 | 1 |