Skip to content

Min

min validates that a number is greater than or equal to a specified minimum value.

It enforces strict numeric validation and rejects any non-number value or number below the threshold. If the value is not a number or is too small, the rule emits a single validation event. Otherwise, it produces no validation output.

Signature

Through the API:

.min(minimum: number)

And internally:

export const min = (limit: number): ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>

Events

Event code Description
type.not.valid Value is not structurally a number or is NaN
number.too.low Number is below the minimum threshold

Design rationale

  • Provides a strict, predictable numeric minimum validation.
  • Rejects non-number values with a clear structural-type diagnostic.
  • 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 JaneEvent objects.

Invoke

min 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 number or is NaN, emits type.not.valid.
  • If the value is a number but less than the minimum, emits number.too.low.
  • If the value is a number at or above the minimum → returns an empty result set.

Examples

Valid number at minimum

await min(18)(18, "$");
// → []

Number below minimum

await min(18)(16, "$");
// → [
//     JaneEvent{
//       kind: "error",
//       code: "number.too.low",
//       path: "$",
//       ...
//     }
//   ]

Non-number value

await min(18)("16", "$");
// → [
//     JaneEvent{
//       kind: "error",
//       code: "type.not.valid",
//       path: "$",
//       ...
//     }
//   ]