From b70210037b6f922a1ea7344bcf1a950611c28e1e Mon Sep 17 00:00:00 2001 From: Luis Felix Date: Wed, 21 Aug 2024 22:15:53 -0400 Subject: [PATCH] OV-29: + utilities methods to validate array and obj --- frontend/src/bundles/common/helpers/helpers.ts | 1 + frontend/src/bundles/common/helpers/utilities.ts | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 frontend/src/bundles/common/helpers/utilities.ts diff --git a/frontend/src/bundles/common/helpers/helpers.ts b/frontend/src/bundles/common/helpers/helpers.ts index 5acdb8642..c2872899c 100644 --- a/frontend/src/bundles/common/helpers/helpers.ts +++ b/frontend/src/bundles/common/helpers/helpers.ts @@ -1 +1,2 @@ +export { isEmptyArray,isNullOrUndefined, isStringNullOrEmpty } from './utilities.js'; export { configureString } from 'shared'; diff --git a/frontend/src/bundles/common/helpers/utilities.ts b/frontend/src/bundles/common/helpers/utilities.ts new file mode 100644 index 000000000..913288a3f --- /dev/null +++ b/frontend/src/bundles/common/helpers/utilities.ts @@ -0,0 +1,9 @@ +const isNullOrUndefined = (value: T | null | undefined): value is null | undefined => + value === undefined || value === null; + +const isStringNullOrEmpty = (value: string | null | undefined): value is null | undefined => + isNullOrUndefined(value) || (value ).trim().length === 0; + +const isEmptyArray = (value: T[]): boolean => isNullOrUndefined(value) || value.length === 0; + +export { isEmptyArray, isNullOrUndefined, isStringNullOrEmpty };