index/functions/validatePaginationParams.md
validatePaginationParams(
offset,limit,contextMessage?):void
Validate pagination parameters
Ensures offset and limit values are valid before using them in API requests. Throws descriptive errors for invalid values.
context message
Parameters
| Parameter | Type | Description |
|---|---|---|
offset | number | Zero-based offset to validate |
limit | number | Limit/page size to validate |
contextMessage? | string | Optional message for error context (e.g., "fetchPools") |
context message
Returns
void
Throws
Error if offset or limit is invalid with descriptive message
Examples
Basic validation
validatePaginationParams(0, 20);
// No error - both valid
validatePaginationParams(-1, 20);
// Throws: "Invalid offset: -1. Offset must be a non-negative integer."
With context
validatePaginationParams(offset, limit, 'fetchTokens');
// Throws: "fetchTokens: Invalid limit: 0. Limit must be a positive integer."
Since
7.0.0