Formify Docs

Between

Enforce an inclusive numeric range

Between

The between rule validates that a numeric value falls within an inclusive range.

Configuration

Config flagTypeDescription
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

ValueRuleResult
1between: [1, 100]✅ Valid (inclusive)
100between: [1, 100]✅ Valid (inclusive)
0between: [1, 100]❌ Invalid
100.5between: [1, 100]❌ Invalid

Things to know

  • Both bounds are inclusive: between: [1, 100] accepts exactly 1 and 100.
  • Non-numeric values fail the comparison — pair with numeric or integer for clearer errors.
  • Equivalent to combining min and max, but keeps the range in one place with a single combined message.

On this page