assertStringLength()function
assertStringLength(value: unknown, min?: number, max?: number, caller: AnyCaller = assertString): asserts value is string
| Param | Type | |
|---|---|---|
value | unknown | The value to assert on. required |
min | number | The minimum allowed length. |
max | number | The maximum allowed length. |
caller | AnyCaller | 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.