@hi-ui/form 4.2.1 → 4.2.2
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 +6 -0
- package/lib/cjs/use-form-field.js +17 -1
- package/lib/esm/use-form-field.js +17 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hi-ui/form
|
|
2
2
|
|
|
3
|
+
## 4.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2933](https://github.com/XiaoMi/hiui/pull/2933) [`369cdf935`](https://github.com/XiaoMi/hiui/commit/369cdf935fb4e3a81478dcbd8e199c1a7cac1875) Thanks [@xiamiao1121](https://github.com/xiamiao1121)! - fix: 修复 validator 回调中第一个参数带有多余的引号
|
|
8
|
+
|
|
3
9
|
## 4.2.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -62,7 +62,23 @@ var useFormField = function useFormField(props) {
|
|
|
62
62
|
}
|
|
63
63
|
// TODO: rules 处理成 Async Validate 的指定结构
|
|
64
64
|
var fieldMD5 = index.stringify(field);
|
|
65
|
-
var
|
|
65
|
+
var modifiedFieldRules = fieldRules.map(function (rule) {
|
|
66
|
+
// 重写 rule 的 validator 函数,正则匹配 validatorRule 中的 field 和 fullField,消除 field 和 fullField 中的双引号
|
|
67
|
+
// issue:https://github.com/XiaoMi/hiui/issues/2931
|
|
68
|
+
if (rule.validator) {
|
|
69
|
+
return Object.assign(Object.assign({}, rule), {
|
|
70
|
+
validator: function validator(validatorRule, value, callback, source, options) {
|
|
71
|
+
var field = validatorRule.field.replace(/"/g, '');
|
|
72
|
+
var fullField = validatorRule.fullField.replace(/"/g, '');
|
|
73
|
+
rule.validator(Object.assign(Object.assign({}, validatorRule), {
|
|
74
|
+
field: field,
|
|
75
|
+
fullField: fullField
|
|
76
|
+
}), value, callback, source, options);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} else return Object.assign({}, rule);
|
|
80
|
+
});
|
|
81
|
+
var validater = new Validater__default["default"]((_Validater = {}, _Validater[fieldMD5] = modifiedFieldRules, _Validater));
|
|
66
82
|
return validater.validate((_validater$validate = {}, _validater$validate[fieldMD5] = valueType !== 'number' || value === '' ? value : isNaN(value) ? value : Number(value), _validater$validate), {
|
|
67
83
|
firstFields: true
|
|
68
84
|
});
|
|
@@ -50,7 +50,23 @@ var useFormField = function useFormField(props) {
|
|
|
50
50
|
}
|
|
51
51
|
// TODO: rules 处理成 Async Validate 的指定结构
|
|
52
52
|
var fieldMD5 = stringify(field);
|
|
53
|
-
var
|
|
53
|
+
var modifiedFieldRules = fieldRules.map(function (rule) {
|
|
54
|
+
// 重写 rule 的 validator 函数,正则匹配 validatorRule 中的 field 和 fullField,消除 field 和 fullField 中的双引号
|
|
55
|
+
// issue:https://github.com/XiaoMi/hiui/issues/2931
|
|
56
|
+
if (rule.validator) {
|
|
57
|
+
return Object.assign(Object.assign({}, rule), {
|
|
58
|
+
validator: function validator(validatorRule, value, callback, source, options) {
|
|
59
|
+
var field = validatorRule.field.replace(/"/g, '');
|
|
60
|
+
var fullField = validatorRule.fullField.replace(/"/g, '');
|
|
61
|
+
rule.validator(Object.assign(Object.assign({}, validatorRule), {
|
|
62
|
+
field: field,
|
|
63
|
+
fullField: fullField
|
|
64
|
+
}), value, callback, source, options);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
} else return Object.assign({}, rule);
|
|
68
|
+
});
|
|
69
|
+
var validater = new Validater((_Validater = {}, _Validater[fieldMD5] = modifiedFieldRules, _Validater));
|
|
54
70
|
return validater.validate((_validater$validate = {}, _validater$validate[fieldMD5] = valueType !== 'number' || value === '' ? value : isNaN(value) ? value : Number(value), _validater$validate), {
|
|
55
71
|
firstFields: true
|
|
56
72
|
});
|