Less than¶
lessThan validates that a number is strictly less than a specified limit.
It enforces strict numeric validation and rejects any non-number value or number that is not less than the threshold. If the value is not a number or is not less than the limit, the rule emits a single validation event. Otherwise, it produces no validation output.
Signature¶
Through the API:
.lessThan(limit: number)
And internally:
export const lessThan = (limit: number): ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>
Events¶
| Event code | Description |
|---|---|
type.not.valid |
Value is not structurally a number |
number.too.high |
Number is not strictly less than the limit |
Design rationale¶
- Provides a strict, predictable upper bound validation (exclusive).
- 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
JaneEventobjects.
Invoke¶
lessThan 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, emits
type.not.valid. - If the value is a number but not less than the limit, emits
number.too.high. - If the value is a number strictly less than the limit → returns an empty result set.
Examples¶
Valid number less than limit¶
await lessThan(10)(5, "$");
// → []
Number equal to limit¶
await lessThan(10)(10, "$");
// → [
// JaneEvent{
// kind: "error",
// code: "number.too.high",
// path: "$",
// ...
// }
// ]
Non-number value¶
await lessThan(10)("5", "$");
// → [
// JaneEvent{
// kind: "error",
// code: "type.not.valid",
// path: "$",
// ...
// }
// ]