fix: 修复 minLength 验证数字时异常的问题 (#5357)

This commit is contained in:
liaoxuezhi 2022-09-15 19:16:44 +08:00 committed by GitHub
parent 7578fea6de
commit 3ba25f54ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -12,7 +12,8 @@ fis.set('project.ignore', [
'scripts/**',
'npm/**',
'gh-pages/**',
'.*/**'
'.*/**',
'node_modules/**'
]);
// 配置只编译哪些文件。

View File

@ -34,7 +34,7 @@
"fis-optimizer-terser": "^1.0.1",
"fis-parser-sass": "^1.2.0",
"fis-parser-svgr": "^1.0.0",
"fis3": "^3.4.41",
"fis3": "^3.5.0-beta.2",
"fis3-deploy-skip-packed": "0.0.5",
"fis3-hook-commonjs": "^0.1.31",
"fis3-hook-node_modules": "^2.3.1",

View File

@ -170,6 +170,11 @@ export const validations: {
return validations.matchRegexp(values, value, /^[A-Z\s\u00C0-\u017F]+$/i);
},
isLength: function (values, value, length) {
// 此方法应该判断文本长度如果传入数据为number导致 maxLength 和 maximum 表现一致了默认转成string
if (typeof value === 'number') {
value = String(value);
}
return !isExisty(value) || isEmpty(value) || value.length === length;
},
equals: function (values, value, eql) {
@ -186,6 +191,10 @@ export const validations: {
return !isExisty(value) || value.length <= length;
},
minLength: function (values, value, length) {
// 此方法应该判断文本长度如果传入数据为number导致 maxLength 和 maximum 表现一致了默认转成string
if (typeof value === 'number') {
value = String(value);
}
return !isExisty(value) || isEmpty(value) || value.length >= length;
},
isUrlPath: function (values, value, regexp) {