Skip to content

Commit 683380e

Browse files
committed
fix(lib): 修复array 多选类型不配置required ,导致array minItems 等后续不校验问题
1 parent 2c2388d commit 683380e

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

packages/lib/src/JsonSchemaForm/common/schema/validate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export function validateFormDataAndTransformMsg({
164164

165165
// 校验required信息 isEmpty 校验
166166
// 如果数组类型针对配置了 format 的特殊处理
167-
const isEmpty = formData === undefined || (schema.type === 'array' && Array.isArray(formData) && formData.length === 0);
167+
const emptyArray = (schema.type === 'array' && Array.isArray(formData) && formData.length === 0);
168+
const isEmpty = formData === undefined || emptyArray;
168169

169170
if (required) {
170171
if (isEmpty) {
@@ -189,7 +190,7 @@ export function validateFormDataAndTransformMsg({
189190
}
190191
return [requireErrObj];
191192
}
192-
} else if (isEmpty) {
193+
} else if (isEmpty && !emptyArray) {
193194
// 非required 为空 校验通过
194195
return [];
195196
}

packages/lib/src/JsonSchemaForm/fields/combiningSchemas/SelectLinkageField/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default {
144144
// 设置新值
145145
if (isObject(newOptionData)) {
146146
Object.entries(newOptionData).forEach(([key, value]) => {
147-
if (value !== undefined && curFormData[key] === undefined) {
147+
if (value !== undefined) {
148148
setPathVal(curFormData, key, value);
149149
}
150150
});

packages/lib/src/JsonSchemaForm/widgets/CheckboxesWidget/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<el-checkbox-group v-model="checkList">
2+
<el-checkbox-group v-model="checkList" v-bind="$attrs">
33
<el-checkbox v-for="(item, index) in enumOptions" :key="index" :label="item.value">{{ item.label }}</el-checkbox>
44
</el-checkbox-group>
55
</template>

0 commit comments

Comments
 (0)