Skip to main content

Function: nonEmpty()

nonEmpty<T>(errorMessage): Validator<T[], T[], string>

Defined in: validation/validators/index.ts:335

Validates array is not empty.

Type Parameters

T

T

Parameters

errorMessage

string

Custom error message

Returns

Validator<T[], T[], string>

Validator that checks non-empty array

Example

nonEmpty('List cannot be empty')([1, 2, 3]) // => Valid([1, 2, 3])
nonEmpty('List cannot be empty')([]) // => Invalid(['List cannot be empty'])