# JSON Schema 验证因未知格式 'date-time' 拒绝有效日期字符串

- **ID:** `data/json-schema-unknown-format`
- **领域:** data
- **类别:** validation_error
- **错误码:** `ValidationError: Unknown format 'date-time'`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

JSON Schema draft-04 使用 'date-time' 格式，但更新版本（draft-06+）拆分为 'date' 和 'time'，部分验证器无法识别组合格式。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| JSON Schema draft-04 | active | — | — |
| JSON Schema draft-06 | active | — | — |
| ajv 8.12.0 | active | — | — |
| jsonschema 4.18.0 | active | — | — |

## 解决方案

1. ```
   Change 'format': 'date-time' to 'format': 'date' and 'format': 'time' as separate properties in draft-06+.
   ```
2. ```
   Use a validator that supports draft-04, e.g., jsonschema with Draft4Validator: from jsonschema import Draft4Validator
   ```
3. ```
   Upgrade the JSON Schema library to a version that auto-detects the draft version from $schema.
   ```

## 无效尝试

- **Adding 'format': 'date-time' to schema definitions** — This is the problematic format itself; validators that don't support it will still reject it. (90% 失败率)
- **Using 'pattern' instead of 'format' with a regex for datetime** — While this works for validation, it does not fix the schema compatibility issue and may be overly restrictive or permissive. (40% 失败率)
