Skip to content

Number is infinite

numberIsInfinite is a built‑in scan rule that detects numeric values that are not finite.

When the value is a number and Number.isFinite(raw) returns false, the rule emits a warn‑level number.not.finite scan event containing the original value. If the value is not a number or is finite, no events are emitted.

Signature

export const numberIsInfinite: ScanRule (raw: unknown, path: FieldPath) => JaneEvent[]
Event code Description
number.not.finite Numeric value is infinite or not finite.

Design rationale

  • Detects infinite numeric values (Infinity, -Infinity) that often indicate upstream calculation errors or malformed input.
  • Uses Number.isFinite() to ensure consistent finite‑number detection.
  • Emits a warning when the value is not finite.
  • Prevents downstream logic from assuming a safe, bounded numeric value.
  • Provides metadata ({ value }) for policy and analysis.
  • Performs no mutation or transformation of the input.

Invoke

numberIsInfinite runs automatically whenever the scan stage is enabled.

  • Enable scan explicitly: jane.value(input).scan().
  • Use a mode that enables scan:
  • strict() enables scan by default.
  • moderate() and lax() 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, numberIsInfinite does not run and no infinite‑value detection occurs.

Examples

Infinite number detected

const result = numberIsInfinite(Infinity, "$");
// → [ JaneEvent{ kind: "warn", code: "number.not.finite", ... } ]

Finite number

const result = numberIsInfinite(42, "$");
// → []

Non‑number value

const result = numberIsInfinite("42", "$");
// → []