Skip to content

Commit

Permalink
OV-29: + utilities methods to validate array and obj
Browse files Browse the repository at this point in the history
  • Loading branch information
lfelix3011 committed Aug 22, 2024
1 parent da525ad commit b702100
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/bundles/common/helpers/helpers.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { isEmptyArray,isNullOrUndefined, isStringNullOrEmpty } from './utilities.js';
export { configureString } from 'shared';
9 changes: 9 additions & 0 deletions frontend/src/bundles/common/helpers/utilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const isNullOrUndefined = <T>(value: T | null | undefined): value is null | undefined =>
value === undefined || value === null;

const isStringNullOrEmpty = (value: string | null | undefined): value is null | undefined =>
isNullOrUndefined<string>(value) || (value ).trim().length === 0;

const isEmptyArray = <T>(value: T[]): boolean => isNullOrUndefined<T[]>(value) || value.length === 0;

export { isEmptyArray, isNullOrUndefined, isStringNullOrEmpty };

0 comments on commit b702100

Please sign in to comment.