mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 00:29:51 +00:00
fix(entity-validator): improve error messaging
This commit is contained in:
parent
7d64a36867
commit
df0fe1c9be
@ -280,7 +280,8 @@ describe('CM API - Basic + dz + draftAndPublish', () => {
|
|||||||
name: 'ValidationError',
|
name: 'ValidationError',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
message: 'Cannot build relations store: "uid" is undefined',
|
message:
|
||||||
|
'Cannot build relations store from dynamiczone, component identifier is undefined',
|
||||||
name: 'ValidationError',
|
name: 'ValidationError',
|
||||||
path: [],
|
path: [],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -310,7 +310,8 @@ describe('CM API - Basic + dz', () => {
|
|||||||
name: 'ValidationError',
|
name: 'ValidationError',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
message: 'Cannot build relations store: "uid" is undefined',
|
message:
|
||||||
|
'Cannot build relations store from dynamiczone, component identifier is undefined',
|
||||||
name: 'ValidationError',
|
name: 'ValidationError',
|
||||||
path: [],
|
path: [],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -293,40 +293,48 @@ const buildRelationsStore = ({ uid, data }) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'component': {
|
case 'component': {
|
||||||
return castArray(value).reduce(
|
return castArray(value).reduce((relationsStore, componentValue) => {
|
||||||
(relationsStore, componentValue) =>
|
if (!attribute.component) {
|
||||||
mergeWith(
|
throw new ValidationError(
|
||||||
relationsStore,
|
`Cannot build relations store from component, component identifier is undefined`
|
||||||
buildRelationsStore({
|
);
|
||||||
uid: attribute.component,
|
}
|
||||||
data: componentValue,
|
|
||||||
}),
|
return mergeWith(
|
||||||
(objValue, srcValue) => {
|
relationsStore,
|
||||||
if (isArray(objValue)) {
|
buildRelationsStore({
|
||||||
return objValue.concat(srcValue);
|
uid: attribute.component,
|
||||||
}
|
data: componentValue,
|
||||||
|
}),
|
||||||
|
(objValue, srcValue) => {
|
||||||
|
if (isArray(objValue)) {
|
||||||
|
return objValue.concat(srcValue);
|
||||||
}
|
}
|
||||||
),
|
}
|
||||||
result
|
);
|
||||||
);
|
}, result);
|
||||||
}
|
}
|
||||||
case 'dynamiczone': {
|
case 'dynamiczone': {
|
||||||
return value.reduce(
|
return value.reduce((relationsStore, dzValue) => {
|
||||||
(relationsStore, dzValue) =>
|
if (!dzValue.__component) {
|
||||||
mergeWith(
|
throw new ValidationError(
|
||||||
relationsStore,
|
`Cannot build relations store from dynamiczone, component identifier is undefined`
|
||||||
buildRelationsStore({
|
);
|
||||||
uid: dzValue.__component,
|
}
|
||||||
data: dzValue,
|
|
||||||
}),
|
return mergeWith(
|
||||||
(objValue, srcValue) => {
|
relationsStore,
|
||||||
if (isArray(objValue)) {
|
buildRelationsStore({
|
||||||
return objValue.concat(srcValue);
|
uid: dzValue.__component,
|
||||||
}
|
data: dzValue,
|
||||||
|
}),
|
||||||
|
(objValue, srcValue) => {
|
||||||
|
if (isArray(objValue)) {
|
||||||
|
return objValue.concat(srcValue);
|
||||||
}
|
}
|
||||||
),
|
}
|
||||||
result
|
);
|
||||||
);
|
}, result);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -350,7 +350,8 @@ describe('Core API - Basic + dz', () => {
|
|||||||
name: 'ValidationError',
|
name: 'ValidationError',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
message: 'Cannot build relations store: "uid" is undefined',
|
message:
|
||||||
|
'Cannot build relations store from dynamiczone, component identifier is undefined',
|
||||||
name: 'ValidationError',
|
name: 'ValidationError',
|
||||||
path: [],
|
path: [],
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user