Is far future¶
isFarFuture validates that a Date instance represents a year strictly greater than 2100.
It performs a strict type check ensuring the value is a valid Date instance, then validates that the year is after 2100. If the value is not a Date, is invalid, or represents a year 2100 or earlier, the rule emits a single validation event. Otherwise, it produces no validation output.
Signature¶
Through the API:
.isFarFuture()
And internally:
export const isFarFuture: ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>
Events¶
| Event code | Description |
|---|---|
date.not.date |
Value is not a Date instance |
date.is.invalid |
Date instance represents an invalid date |
date.is.far-future |
Date represents year 2100 or earlier |
Design rationale¶
- Provides a strict, predictable far-future date validation.
- First ensures the value is a valid Date instance.
- Then validates the year is strictly greater than 2100.
- Useful for preventing data entry errors or enforcing long-term future dates.
- Never coerces or normalizes — validation is explicit and opt-in.
- Emits exactly one event per failure for clarity and composability.
- Async-compatible and returns a readonly array of
JaneEventobjects.
Invoke¶
isFarFuture runs only when explicitly included in a boundary or pipeline. It does not run automatically.
The rule activates when:
- The value is any JavaScript value.
- If the value is not a Date instance, emits
date.not.date. - If the value is a Date but invalid, emits
date.is.invalid. - If the value is a valid Date but year ≤ 2100, emits
date.is.far-future. - If the value is a valid Date after 2100 → returns an empty result set.
Examples¶
Far future date¶
await isFarFuture(new Date("2200-01-01"), "$");
// → []
Recent date¶
await isFarFuture(new Date("2023-01-01"), "$");
// → [
// JaneEvent{
// kind: "error",
// code: "date.is.far-future",
// path: "$",
// ...
// }
// ]
Non-Date value¶
await isFarFuture("2200-01-01", "$");
// → [
// JaneEvent{
// kind: "error",
// code: "date.not.date",
// path: "$",
// ...
// }
// ]