Between
Enforce an inclusive numeric range
Between
The between rule validates that a numeric value falls within an inclusive range.
Configuration
| Config flag | Type | Description |
|---|---|---|
between | [min, max] | Inclusive lower and upper bounds. |
between | [[min, max], string] | Tuple form — the bounds plus a custom message. |
validationSchema: {
score: { between: [1, 100] },
}With a custom message:
score: { between: [[1, 100], "Score must be between 1 and 100"] }V builder
import { V } from "formify-js";
V.between(1, 100)
V.between(1, 100, "Score must be between 1 and 100")Default message
The default message interpolates the bounds, e.g. Must be between 1 and 100 ({min} / {max} placeholders).
Examples
| Value | Rule | Result |
|---|---|---|
1 | between: [1, 100] | ✅ Valid (inclusive) |
100 | between: [1, 100] | ✅ Valid (inclusive) |
0 | between: [1, 100] | ❌ Invalid |
100.5 | between: [1, 100] | ❌ Invalid |
Things to know
- Both bounds are inclusive:
between: [1, 100]accepts exactly1and100. - Non-numeric values fail the comparison — pair with
numericorintegerfor clearer errors. - Equivalent to combining
minandmax, but keeps the range in one place with a single combined message.