Skip to content

Commit

Permalink
fix: 修复errorMessage在对象数组未透传问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mengshang918 committed Jan 20, 2022
1 parent 5f0f211 commit d69d1d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 8 additions & 0 deletions packages/utils/__testsdata__/array.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export const unitedSchema = {
mode: 'add',
addTitle: '添加一行数据',
},
minItems: 1,
errMsg: {
minItems: '最小1',
},
items: {
validateTime: 'submit',
type: 'string',
Expand Down Expand Up @@ -41,6 +45,10 @@ export const parsedSchema = {
validateTime: 'submit',
type: 'array',
title: '数组容器',
minItems: 1,
errorMessage: {
minItems: '最小1',
},
items: {
validateTime: 'submit',
type: 'string',
Expand Down
13 changes: 7 additions & 6 deletions packages/utils/src/schemaHandle/combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ function valueClone({
}
}

if (
dataType &&
!['object', 'array'].includes(dataType) &&
Object.hasOwnProperty.call(rawObj, 'errorMessage')
) {
if (dataType && Object.hasOwnProperty.call(rawObj, 'errorMessage')) {
targetObj.errMsg = deepClone(rawObj.errorMessage)
if (targetObj.errMsg.required) {
delete targetObj.errMsg.required
if (Object.keys(targetObj.errMsg).length === 0) {
delete targetObj.errMsg
}
}
}
}

Expand All @@ -74,7 +76,6 @@ function recursionCombine(
rawObj: dataSchema,
dataType: dataSchema.type,
})

// uiSchema非空时进行拷贝
if (!isEmpty(uiSchema)) {
// 填充ui属性,用于存放uiSchema
Expand Down

0 comments on commit d69d1d6

Please sign in to comment.