-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Xziy
committed
Aug 19, 2024
1 parent
84fb431
commit 8832853
Showing
3 changed files
with
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export function isValue<T>(value: T): boolean { | ||
// Check for undefined and null | ||
if (value === undefined || value === null) { | ||
return false; | ||
} | ||
|
||
// Check for NaN (only if the value is of type number) | ||
if (typeof value === 'number' && Number.isNaN(value)) { | ||
return false; | ||
} | ||
|
||
// Check for empty strings | ||
if (typeof value === 'string' && value.trim() === '') { | ||
return false; | ||
} | ||
|
||
// Check for empty arrays | ||
if (Array.isArray(value) && value.length === 0) { | ||
return false; | ||
} | ||
|
||
// Check for empty objects | ||
if (typeof value === 'object' && Object.keys(value).length === 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|