It Should Help

String Verifier Reference

Created by should().string(entry: string | null | undefined).

Methods

Method

Passes when

equals(expected: string \| null \| undefined)

strictly equal, case-sensitive

equalsIgnoreCase(expected: string \| null \| undefined)

equal after upper-casing both sides (skips the definedness guard — see Caveats)

hasLength(expected: number)

entry.length === expected

empty()

zero length (sugar for hasLength(0))

whitespace()

empty, or only space characters after removal

upperCased()

entry === entry.toUpperCase()

lowerCased()

entry === entry.toLowerCase()

contains(expected: string, counter?: (count: number) => boolean)

occurrence count of expected satisfies counter (default: at least once)

containsIgnoreCase(expected: string, counter?)

same, case-insensitive

containsAny(...expected: string[])

contains at least one of the arguments

containsAnyIgnoreCase(...expected: string[])

same, case-insensitive

match(exp: string \| RegExp)

entry.match(exp) is truthy — a partial match

Plus the inherited not and defined().

Times counters

Times builds the counter predicates for the contains family:

Helper

Predicate

Times.exactly(n)

count === n

Times.once()

count === 1

Times.twice()

count === 2

Times.moreThan(n)

count > n (exclusive)

Times.lessThan(n)

count < n (exclusive)

Any custom (count: number) => boolean may be passed instead.

Representative messages

  • `'${expected}' doesn't equal '${real}'.` (equals)

  • `'${real}' is not whitespace.`/`'${real}' is not uppercased.`

  • `'${real}' does not match ${exp}.` (match)

Guide: Strings.

02 сентября 2026