Skip to main content
io.input.number() requests a number. Provided by the @awaitio/input-number package.
A Refund amount field filled with 49.90, with help text under it

Install

Setup

Register it under the key you want in io, see Input components:
app.ts

Usage

Props

Props are checked when the io call is made: a prop of the wrong type throws in the handler.

Optional

The field is required. Chain .optional() to let it stay empty; the handler then gets number | undefined, see Optional fields.

Returns

number, already checked against min, max and decimals: typing 49.90 gives 49.9.

Built-in validation

The field is always required. The browser stops values outside the limits before they are sent, and the server checks every answer again, so these messages come back even when the browser’s own checks are bypassed:

Custom validation

Chain .validate() for a check of your own. It runs on the server after the checks above, gets the value the handler would get and returns a message to show under the field, or nothing when the value is fine; see Custom validation.