assertStringLength()function

assertStringLength(value: unknown, min?: number, max?: number, caller: AnyCaller = assertString): asserts value is string
ParamType
valueunknown
The value to assert on. required
minnumber
The minimum allowed length.
maxnumber
The maximum allowed length.
callerAnyCaller
Function to attribute a thrown error to (defaults to assertString). Defaults to assertString
Return
asserts value is string
Throws
RequiredError
If value is not a string within the length bounds.

Assert that a value is a string with a length between min and max.

Examples

assertStringLength("abc", 1, 5); // Passes.