It Should Help

Array Verifier Reference

Created by should().array<T>(entry: (T | null | undefined)[] | null | undefined).

Methods

Method

Passes when

empty()

the array has no items

length(expected: number)

exact item count

ordered(settings?: ArrayOrderedSettings<T>)

neighbors satisfy the ordering — see below

contain(expected: T, identifier?)

at least one element matches expected (by identifier or ===)

containExactly(times: number, expected: T, identifier?)

exactly times occurrences

containBy(condition: (e?: T \| null) => boolean)

at least one element satisfies the condition

containByExactly(times: number, condition)

exactly times elements satisfy the condition

containOnly(condition)

every element satisfies the condition

uniq(identifier?)

no duplicates by identifier (or value)

equal(expected: T[], identifier?)

same elements, same order

equalUnordered(expected: T[], identifier?)

same elements, any order

Plus the inherited not and defined().

The identifier parameter

(e?: T | null) => any — extracts the comparison key from an element. Defaults to the element itself, which makes object comparisons reference-based; always provide it for object collections (Arrays).

ArrayOrderedSettings<T>

Field

Type

Default

by

(e?: T \| null) => any — comparable extractor

x => x

dir

'asc' \| 'desc'

'asc'

Neighbors compare with <= (asc) / >= (desc); equal neighbors are allowed in both directions. Deep dive: Array Ordering.

Representative messages

  • The collection is not empty./The collection is empty.

  • Elements aren't ordered./Elements are ordered.

  • The collection doesn't contain the expected element.

  • The collections are not equal.

02 сентября 2026