Skip to content

@jsvision/ui / range

Function: range()

range(min, max): Validator

Defined in: ui/src/controls/validators/range.ts:33

Build an integer-range validator.

Parameters

min

number

The inclusive lower bound. A negative min also permits typing a leading -.

max

number

The inclusive upper bound.

Returns

Validator

A Validator that filters keystrokes to digits/signs and, on completion, requires the value to parse to an integer within [min, max].

Example

ts
import { signal } from '@jsvision/ui';
import { Input, range } from '@jsvision/ui';

const age = signal('');
// Accepts 0–120; non-digits are rejected live, out-of-range flags invalid on focus-leave.
const input = new Input({ value: age, validator: range(0, 120) });