Components

Currency

Usage

const estimate = await io.input.currency('Quote price')
console.log(estimate) // '5.00'

Parameters

labelrequired
string

The label to render above the input.

options { ... }
defaultValue
number

Default value rendered in input. Default 0.

displayLocale
string

Display locale for the input. Default 'en-US'.

currency
string

Currency code for the input. Default 'USD'. See: https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes

decimals
number

The number of decimals for the input. Affects the input masking and return value (adds trailing zeros). Default 2.

minDecimals
number

The minimum number of decimals for the input. Default 2.

valueFormat
'number' | 'string'

Numeric value or parsed string value. Default 'number'. Example return values '$5,001.00' vs. '5001'.

step
number

The amount to increment on arrow key events. Default 1.

min
number | undefined

Minimum value rendered in input. Default undefined.

max
number | undefined

Maximum value rendered in input. Default undefined.

disabled
boolean

Disables user input. Default false.

help
string

The small help text to render below the input. Default ''.

customValidator
(input: unknown) => Promise<string | true>

An asynchronous function that takes unknown input and outputs either true or an error message string to show the user.