From 44a36fdf30a0557062668367c92e119e4c0c0f54 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 26 Jan 2022 00:05:18 +0200 Subject: [PATCH] Fix validating empty icon sets --- packages/utils/src/icon-set/validate.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/utils/src/icon-set/validate.ts b/packages/utils/src/icon-set/validate.ts index ce6ea45..f92a35c 100644 --- a/packages/utils/src/icon-set/validate.ts +++ b/packages/utils/src/icon-set/validate.ts @@ -173,8 +173,17 @@ export function validateIconSet( } }); + // Check not_found + if (data.not_found !== void 0 && !(data.not_found instanceof Array)) { + if (fix) { + delete data.not_found; + } else { + throw new Error('Invalid not_found list'); + } + } + // Make sure icons list is not empty - if (!Object.keys(data.icons).length) { + if (!Object.keys(data.icons).length && !data.not_found?.length) { throw new Error('Icon set is empty'); }