Skip to content

Date is far future

dateIsFarFuture is a built‑in scan rule that detects Date values whose timestamp occurs far beyond a conservative future boundary.

When the value is a Date instance and its timestamp exceeds 2100‑01‑01T00:00:00.000Z, the rule emits a warn‑level date.is.far-future scan event containing the observed timestamp and the configured maximum. If the value is not a Date or does not exceed the boundary, no events are emitted.

Signature

export const dateIsFarFuture: ScanRule (raw: unknown, path: FieldPath) => JaneEvent[]

Events

Event code Description
date.is.far-future Date timestamp exceeds the far‑future threshold.

Design rationale

  • Detects timestamps that fall far beyond realistic operational horizons.
  • Uses a fixed upper boundary (2100‑01‑01T00:00:00.000Z) to surface corrupted, adversarial, or implausible future dates.
  • Emits a warning when the timestamp exceeds the boundary.
  • Provides metadata ({ timestamp, max }) for policy and analysis.
  • Performs no mutation or transformation of the input.

Invoke

dateIsFarFuture 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() 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 Date instance, dateIsFarFuture does not run and no far‑future detection occurs.

Examples

Far‑future date detected

const result = dateIsFarFuture(new Date("2200-01-01"), "$");
// → [ JaneEvent{ kind: "warn", code: "date.is.far-future", ... } ]

Date within safe future range

const result = dateIsFarFuture(new Date("2050-01-01"), "$");
// → []

Non‑Date value

const result = dateIsFarFuture("2100-01-01", "$");
// → []