schema-dsl 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -11,6 +11,7 @@
11
11
 
12
12
  | 版本 | 日期 | 变更摘要 | 详细 |
13
13
  |------------------|------|---------|------|
14
+ | [v1.1.3](#v113) | 2026-01-09 | 🐛 Bug修复:类型错误消息模板变量未替换 | [查看详情](#v113) |
14
15
  | [v1.1.2](#v112) | 2026-01-06 | 🎉 新功能:数字比较运算符 + Bug修复 | [查看详情](#v112) |
15
16
  | [v1.1.1](#v111) | 2026-01-06 | 🎉 新功能:ConditionalBuilder 独立消息支持 | [查看详情](#v111) |
16
17
  | [v1.1.0](#v110) | 2026-01-05 | 🎉 重大功能:跨类型联合验证 + 插件系统增强 | [查看详情](#v110) |
@@ -27,6 +28,44 @@
27
28
 
28
29
  ---
29
30
 
31
+ ## [v1.1.3] - 2026-01-09
32
+
33
+ ### 🐛 Bug 修复
34
+
35
+ #### 类型验证错误消息模板变量未替换
36
+
37
+ **问题描述**:
38
+ 当类型验证失败时,错误消息中的 `{{#actual}}` 模板变量没有被替换,导致错误消息显示不完整。
39
+
40
+ **修复前**:
41
+ ```javascript
42
+ const schema = dsl({ age: 'string!' });
43
+ const result = validate(schema, { age: 25 });
44
+ // ❌ 错误消息: "age should be string, got {{#actual}}"
45
+ ```
46
+
47
+ **修复后**:
48
+ ```javascript
49
+ const schema = dsl({ age: 'string!' });
50
+ const result = validate(schema, { age: 25 });
51
+ // ✅ 错误消息: "age should be string, got number"
52
+ ```
53
+
54
+ **修复内容**:
55
+ - ✅ 在 `ErrorFormatter.formatDetailed()` 中添加 `actual` 参数计算逻辑
56
+ - ✅ 支持正确显示实际数据类型:`number`, `string`, `boolean`, `object`, `array`, `null`, `undefined`
57
+ - ✅ 修复文件:`lib/core/ErrorFormatter.js` 第 280-284 行
58
+
59
+ **影响范围**:
60
+ - ✅ 仅影响类型验证错误消息的显示
61
+ - ✅ 不影响验证逻辑本身
62
+ - ✅ 向后兼容,无破坏性变更
63
+
64
+ **感谢**:
65
+ 感谢 monSQLize 项目发现并报告此问题。
66
+
67
+ ---
68
+
30
69
  ## [v1.1.2] - 2026-01-06
31
70
 
32
71
  ### 🎉 新功能
package/STATUS.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # schema-dsl 项目状态
2
2
 
3
- > **最后更新**: 2026-01-06
4
- > **当前版本**: v1.1.1
3
+ > **最后更新**: 2026-01-09
4
+ > **当前版本**: v1.1.3
5
5
  > **项目状态**: ✅ 全部完成,测试100%通过(921个测试)
6
6
 
7
7
  ---
8
8
 
9
9
  ## 📋 目录
10
10
 
11
+ - [v1.1.3](#v113) - 2026-01-09 ✅ 已完成
11
12
  - [v1.1.1](#v111) - 2026-01-06 ✅ 已完成
12
13
  - [v1.1.0](#v110) - 2026-01-05 ✅ 已完成
13
14
  - [v1.0.9](#v109) - 2026-01-04 ✅ 已完成
@@ -25,6 +26,38 @@
25
26
 
26
27
  ## 版本发布计划
27
28
 
29
+ ### v1.1.3
30
+
31
+ **发布日期**: 2026-01-09
32
+ **状态**: ✅ 已完成
33
+ **类型**: 🐛 Bug修复 - 类型错误消息模板变量未替换
34
+ **进度**: 100%完成 | 测试: 921个通过
35
+
36
+ | 需求标题 | 状态 | 优先级 | 详细 |
37
+ |---------|------|--------|------|
38
+ | 修复类型错误消息模板 | ✅ 完成 | P0 | `{{#actual}}` 变量未替换 |
39
+ | 添加 actual 参数计算 | ✅ 完成 | P0 | 正确显示实际数据类型 |
40
+ | 更新 CHANGELOG | ✅ 完成 | P0 | v1.1.3 变更记录 |
41
+ | 更新 STATUS | ✅ 完成 | P0 | 版本号和状态 |
42
+
43
+ **实现状态统计**:
44
+ - ✅ 完成: 4个
45
+ - 🔄 进行中: 0个
46
+ - ⏳ 待完成: 0个
47
+
48
+ **核心变更**:
49
+ - ✅ **修复**: ErrorFormatter.formatDetailed() 添加 `actual` 参数
50
+ - ✅ **修复**: 类型错误消息正确显示实际数据类型
51
+ - ✅ **支持**: `number`, `string`, `boolean`, `object`, `array`, `null`, `undefined`
52
+
53
+ **Bug 详情**:
54
+ - **问题**: `{{#actual}}` 模板变量未被替换
55
+ - **原因**: `interpolateData` 缺少 `actual` 参数
56
+ - **修复**: 添加类型计算逻辑(第 280-284 行)
57
+ - **影响**: 仅影响错误消息显示,不影响验证逻辑
58
+
59
+ ---
60
+
28
61
  ### v1.1.1
29
62
 
30
63
  **发布日期**: 2026-01-06
@@ -277,7 +277,12 @@ class ErrorFormatter {
277
277
  // 映射 min/max 以匹配模板
278
278
  min: limit,
279
279
  max: limit,
280
- expected: err.params ? err.params.type : undefined
280
+ expected: err.params ? err.params.type : undefined,
281
+ // ✅ 修复:添加 actual 参数 - 实际接收到的数据类型
282
+ actual: err.data === null ? 'null' :
283
+ err.data === undefined ? 'undefined' :
284
+ Array.isArray(err.data) ? 'array' :
285
+ typeof err.data
281
286
  };
282
287
 
283
288
  message = this._interpolate(message, interpolateData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schema-dsl",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "简洁强大的JSON Schema验证库 - DSL语法 + String扩展 + 便捷validate",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",