Skip to content

Commit

Permalink
fixed due to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed May 29, 2021
1 parent 69afcef commit fccdb71
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@ export const validateRuleActionsField = (actionTypeRegistry: ActionTypeRegistryC
): Promise<ValidationError<ERROR_CODE> | void | undefined> => {
const [{ value, path }] = data as [{ value: AlertAction[]; path: string }];

const errors = await value.reduce(async (acc, actionItem) => {
const errors = [];
for (const actionItem of value) {
const errorsArray = await validateSingleAction(actionItem, actionTypeRegistry);

if (errorsArray.length) {
const actionTypeName = getActionTypeName(actionItem.actionTypeId);
const errorsListItems = errorsArray.map((error) => `* ${error}\n`);

return [...(await acc), `\n**${actionTypeName}:**\n${errorsListItems.join('')}`];
errors.push(`\n**${actionTypeName}:**\n${errorsListItems.join('')}`);
}

return acc;
}, Promise.resolve([] as string[]));
}

if (errors.length) {
return {
Expand Down

0 comments on commit fccdb71

Please sign in to comment.