Skip to main content

Function: normalizeHistoryLimit()

normalizeHistoryLimit(candidate: number, rules: HistoryLimitRules): number

Defined in: shared/constants/history.ts:58

Computes the effective history limit after applying business rules.

Parametersโ€‹

candidateโ€‹

number

History limit provided by a consumer.

rulesโ€‹

HistoryLimitRules = DEFAULT_HISTORY_LIMIT_RULES

Rules to use when normalising the value. Defaults to the shared history limit rules used across the application.

Returnsโ€‹

number

The normalised history limit ready for persistence.

Remarksโ€‹

Validates that the candidate is a finite number within the supported bounds, then clamps values below the minimum to the configured minimum while treating zero or negative inputs as "unlimited" (represented as 0). Fractional values above the minimum are preserved to avoid surprising the caller.

Throwsโ€‹

TypeError - When the candidate is not a finite number or integer.

Throwsโ€‹

RangeError - When the candidate exceeds the configured maximum.