isValid
isValid(
item):boolean
Defined in: validations.ts:28
Check that a value is present and, when it is an array, not empty.
Only null, undefined and empty arrays are rejected. Every other value counts as valid, including
non-array values such as numbers, strings, objects and booleans (false and 0 included).
Parameters
Section titled “Parameters”unknown
The value to check.
Returns
Section titled “Returns”boolean
false when item is null, undefined or an empty array, otherwise true.
Remarks
Section titled “Remarks”Despite the package name, the check is not limited to arrays: it is a guard for “something worth working with”, so a value can be passed through it before being iterated or spread.
Example
Section titled “Example”import { isValid } from "@theholocron/array-utils";
isValid([1, 2, 3]); // trueisValid([]); // falseisValid(null); // falseisValid(undefined); // falseisValid("hello"); // trueisValid(0); // true