assertInteger()function
assertInteger(value: unknown, min?: number, max?: number, caller: AnyCaller = assertInteger): asserts value is number
| Param | Type | |
|---|---|---|
value | unknown | The value to assert. required |
min | number | Minimum allowed value, inclusive. |
max | number | Maximum allowed value, inclusive. |
caller | AnyCaller | Function used to attribute a thrown error to the calling site. Defaults to assertInteger |
| Return | |
|---|---|
asserts value is number | Nothing; narrows value to number. |
| Throws | |
|---|---|
unknown | RequiredError if value is not an integer within range. |
Assert that a value is an integer (optionally within specified min/max values).
Examples
assertInteger(5, 0, 10); // passes