-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance samplers input-validation with isEmpty function
- Loading branch information
1 parent
0168951
commit 9047f3f
Showing
6 changed files
with
36 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './compare-condition'; | ||
export * from './get-value-for-range'; | ||
export * from './is-emtpy'; |
12 changes: 12 additions & 0 deletions
12
frontend/webapp/utils/functions/resolvers/is-emtpy/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Sometimes we need to allow "zero" values, and a simple "!val" check would result in false positives. | ||
// This function is a strict check for empty values, permitting values like "0" and "false". | ||
|
||
export const isEmpty = (val: any) => { | ||
if (Array.isArray(val)) { | ||
return !val.length; | ||
} else if (typeof val === 'object') { | ||
return !Object.keys(val).length; | ||
} else { | ||
return [undefined, null, ''].includes(val); | ||
} | ||
}; |