diff --git a/striker-ui/lib/isEmpty.ts b/striker-ui/lib/isEmpty.ts index d2fd1970..23be50ce 100644 --- a/striker-ui/lib/isEmpty.ts +++ b/striker-ui/lib/isEmpty.ts @@ -1,4 +1,7 @@ -type IsEmptyTypeMap = Pick; +type IsEmptyTypeMap = Pick< + MapToType, + 'number' | 'object' | 'string' | 'undefined' +>; type MapToValueIsEmptyFunction = { [TypeName in keyof IsEmptyTypeMap]: ( @@ -8,6 +11,7 @@ type MapToValueIsEmptyFunction = { const MAP_TO_VALUE_IS_EMPTY_FUNCTION: MapToValueIsEmptyFunction = { number: (value = 0) => value === 0, + object: (value) => Object.keys(value).length === 0, string: (value = '') => value.trim().length === 0, undefined: () => true, }; diff --git a/striker-ui/types/MapToType.d.ts b/striker-ui/types/MapToType.d.ts index e400ab34..2cf693ff 100644 --- a/striker-ui/types/MapToType.d.ts +++ b/striker-ui/types/MapToType.d.ts @@ -1,6 +1,7 @@ declare type MapToType = { boolean: boolean; number: number; + object: Record; string: string; undefined: undefined; };