# JSON Schema 验证失败：format 'date-time' 拒绝带时区偏移的合法 ISO 8601 时间戳

- **ID:** `data/json-schema-format-date-time-ambiguity`
- **领域:** data
- **类别:** validation_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

某些验证器（如旧版 ajv）中 JSON Schema 的 'date-time' 格式要求时间戳以 'Z'（UTC）结尾，拒绝像 '+05:30' 或 '-08:00' 这样的合法 ISO 8601 偏移。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| ajv 6.12.6 | active | — | — |
| jsonschema 4.17.3 | active | — | — |
| json-schema-validator 4.0.1 | active | — | — |

## 解决方案

1. ```
   Update to a newer validator version that supports RFC 3339 full format: npm install ajv@8.12.0 (for JavaScript) or pip install jsonschema[format-nongpl] (for Python, which uses rfc3339-validator).
   ```
2. ```
   Use a custom format validator that accepts all ISO 8601 timezone offsets. Example in Python: from jsonschema import validators; from rfc3339_validator import validate_rfc3339; validator = validators.validate(..., format_checker=validators.Draft7Validator.FORMAT_CHECKER.replaces('date-time', lambda instance: validate_rfc3339(instance)))
   ```

## 无效尝试

- **** — Changes the data value, potentially breaking downstream timezone-sensitive logic. Also requires modifying the data source, which may not always be feasible. (60% 失败率)
- **** — Validates only the date part, ignoring time entirely, which may not meet the schema's intent. (75% 失败率)
