Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
add recursive dynamic validation
Browse files Browse the repository at this point in the history
  • Loading branch information
EdisonPeM committed Jun 19, 2021
1 parent d24dd27 commit b0f4928
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion services/utils/contentChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,29 @@ async function getValidComponent(value, attribute, user) {
}

async function getValidDynamic(value, attribute, user) {
return value;
const { components } = attribute;
const dynamicValues = Array.isArray(value) ? value : [];

return Promise.all(
dynamicValues.map(async (dynamicComponent) => {
const { __component } = dynamicComponent;
if (
!__component ||
!components.includes(__component) ||
!strapi.components[__component]
) {
return null;
}

const { attributes } = strapi.components[__component];
const content = await getValidSingleComponent(
dynamicComponent,
attributes,
user
);
return { __component, ...content };
})
);
}

module.exports = {
Expand Down

0 comments on commit b0f4928

Please sign in to comment.