Number is too large¶
numberIsTooLarge is a built‑in scan rule that detects numeric values whose magnitude exceeds a conservative safety threshold.
When the value is a number and its absolute value is greater than 1e15, the rule emits a warn‑level number.is.too-large scan event containing the observed value and the configured maximum. If the value is not a number or does not exceed the threshold, no events are emitted.
Signature¶
export const numberIsTooLarge: ScanRule (raw: unknown, path: FieldPath) => JaneEvent[]
Events¶
| Event code | Description |
|---|---|
number.is.too-large |
Number magnitude exceeded the safe threshold. |
Design rationale¶
- Detects extremely large numeric values that may indicate corrupted, unrealistic, or adversarial input.
- Uses a conservative magnitude limit (
1e15) aligned with cross‑platform numeric safety boundaries. - Emits a warning when the absolute value exceeds the threshold.
- Helps prevent downstream systems from encountering overflow, precision loss, or performance issues.
- Provides metadata (
{ value, max }) for policy and analysis. - Performs no mutation or transformation of the input.
Invoke¶
numberIsTooLarge runs automatically whenever the scan stage is enabled.
Activation methods:
- Enable scan explicitly:
jane.value(input).scan(). - Use a mode that enables scan:
strict()enables scan by default.moderate()andlax()do not enable scan unless.scan()is called.- Enable scan with policy:
jane.value(input).withPolicy({ mode: 'strict' }).
If scan is not enabled or if the value is not a number, numberIsTooLarge does not run and no magnitude detection occurs.
Examples¶
Large number detected¶
const result = numberIsTooLarge(9e20, "$");
// → [ JaneEvent{ kind: "warn", code: "number.is.too-large", ... } ]
Number within safe magnitude¶
const result = numberIsTooLarge(12345, "$");
// → []
Non‑number value¶
const result = numberIsTooLarge("12345", "$");
// → []