index/functions/normalizeLimit.md
normalizeLimit(
limit,minLimit?,maxLimit?):number
Normalize limit to ensure it's within valid bounds
Ensures limit is between min and max bounds. Useful for enforcing server-side pagination constraints. Accepts undefined and returns minLimit.
min limit max
Parameters
| Parameter | Type | Description |
|---|---|---|
limit | number | undefined | Limit to normalize (undefined returns minLimit) |
minLimit? | number | Minimum allowed limit (default: 1) |
maxLimit? | number | Maximum allowed limit (default: PAGINATION_DEFAULTS.BACKEND_MAX_PAGE_SIZE) |
min limit max
Returns
number
Normalized limit within bounds
Example
normalizeLimit(undefined) // Returns: 1
normalizeLimit(0) // Returns: 1
normalizeLimit(100) // Returns: 20 (if maxLimit is 20)
normalizeLimit(10) // Returns: 10 (within bounds)
normalizeLimit(100, 1, 50) // Returns: 50 (custom max)
Since
6.5.0