isNonEmpty
Checks if a string is non-empty (has at least one character).
null and undefined are considered empty and return false.
Whitespace-only strings are considered non-empty.
Use isNonEmpty(value?.trim()) if you need to exclude blank strings.
Available since v2.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | null | undefined | The string to check |
Returns
Section titled “Returns”value is string — true if the string has at least one character; false for "", null, or undefined.
Acts as a type guard: the if branch narrows string | null | undefined to string.
Examples
Section titled “Examples”Check if a string has content
Section titled “Check if a string has content”Returns true for any string with at least one character, including whitespace.
Exclude blank strings by trimming first
Section titled “Exclude blank strings by trimming first”Compose with .trim() when whitespace-only strings should be treated as empty.
