From 89ad9d34e96a082c69cb0f2e336aa45715becd83 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Tue, 26 Jul 2022 18:41:01 -0400 Subject: [PATCH] fix(striker-ui): allow undefined in isEmpty element(s) --- striker-ui/lib/isEmpty.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/striker-ui/lib/isEmpty.ts b/striker-ui/lib/isEmpty.ts index 248ac067..d4cd34c8 100644 --- a/striker-ui/lib/isEmpty.ts +++ b/striker-ui/lib/isEmpty.ts @@ -1,14 +1,16 @@ type MapToValueIsEmptyFunction = { - [TypeName in keyof MapToType]: (value: MapToType[TypeName]) => boolean; + [TypeName in keyof MapToType]: ( + value: MapToType[TypeName] | undefined, + ) => boolean; }; const MAP_TO_VALUE_IS_EMPTY_FUNCTION: MapToValueIsEmptyFunction = { - number: (value: number) => value === 0, - string: (value: string) => value.trim().length === 0, + number: (value = 0) => value === 0, + string: (value = '') => value.trim().length === 0, }; const isEmpty = ( - values: Array, + values: Array, { not, fn = 'every' }: { not?: boolean; fn?: 'every' | 'some' } = {}, ): boolean => values[fn]((value) => {