Dromo supports a variety of field types, each with their own unique properties and behaviors. This section describes the different types of fields available and their usage.
type
parameter in the field object. This can be a string referring to one of the field types, explained below. Alternatively, some field types can take additional options controlling their behavior and format. In this case, you can provide the type
parameter with a 2-element array, where the first element is the type name and the second element is any options that field type takes.
type: "string"
By default (if no field type is specified), all fields in Dromo have the string
type. This is the simplest field type, and does not do any validation or transformation of the data – the data is output as a string exactly as it was entered.The string type does not take any options.type: "number"
type: ["number", <preset name string>]
type: ["number", "usd"]
.Here are all of the presets that Dromo provides:Preset Name | Source value | Display value |
---|---|---|
default (used if no display settings are given) | 1234567.1234567 | 1,234,567.1234567 |
percent | 0.12340.56 | 12.34%56% |
plain | 1234567.123 | 1234567.123 |
usd | 1234.567-3456.78 | 3,456.78 |
usd_accounting | 1234.567-3456.78 | (3,456.78) |
eur | 1234.567-3456.78 | 1,234.57 €-3,456.78 € |
gbp | 1234.567-3456.78 | £ 1,234.57- £3,456.78 |
decimal_0 orinteger | 234.567 | 235 |
decimal_1 | 234.567123 | 234.6123.0 |
decimal_2 | 234.567123 | 234.57123.00 |
decimal_3 | 234.5678123 | 234.568123.000 |
decimal_4 | 234.56789123 | 234.5679123.0000 |
percent_0 | 0.1256 | 13% |
percent_1 | 0.12560.34 | 12.6%34.0% |
percent_2 | 0.125670.34 | 12.57%34.00% |
percent_3 | 0.1234560.34 | 12.346%34.000% |
percent_4 | 0.123456780.34 | 12.3457%34.0000% |
round
setting takes an integer which defines how many digits after the decimal point the value will be rounded to. Negative values will round to digits before the decimal.The displayFormat
and outputFormat
settings can be used for creating your own custom formats. The displayFormat
is used for displaying the number to the user on the review screen. The outputFormat
, if set, will determine how the number is output in the result JSON, as a string.For more information on using displayFormat
and outputFormat
, see the number formatting section.min
and max
settings.The min
and max
settings are optional and you can specify none, one or both. If a given number falls below the min
or above the max
, a validation error will be added to the field.
type: "date"
"2022-03-27"
).You can specify a locale for the date field, which must be a valid BCP 47 locale string. If not provided, the locale defaults to "en-US"
.The locale will change how the date is displayed to the user with the display format. The locale will also affect the output format if a custom format is used.The default display format is the standard short form in the configured locale, for example:Locale | Default format example |
---|---|
en-US | 3/27/2022 |
ar-SY | ٢٧/٣/٢٠٢٢ |
de-DE | 27.3.2022 |
pt-BR | 27/03/2022 |
th-TH | 27/3/2565 |
zh-CN | 2022/3/27 |
type: "datetime"
"2022-03-27T15:20"
).By default, seconds are neither displayed nor output. You can change this by providing withSeconds: true
in the field settings.You can specify a locale for the datetime field, which must be a valid BCP 47 locale string. If not provided, the locale defaults to "en-US"
.The locale will change how the datetime is displayed to the user with the display format. The locale will also affect the output format if a custom format is used.The default display format is the standard short form in the configured locale, for example:Locale | Default format example |
---|---|
en-US | 3/27/2022, 3:20 PM |
ar-SY | ٢٧/٣/٢٠٢٢, ٣:٢٠ م |
de-DE | 27.3.2022, 15:20 |
pt-BR | 27/03/2022 15:20 |
th-TH | 27/3/2565 15:20 |
zh-CN | 2022/3/27 下午3:20 |
type: "time"
"15:20"
).By default, seconds are neither displayed nor output. You can change this by providing withSeconds: true
in the field settings.You can specify a locale for the datetime field, which must be a valid BCP 47 locale string. If not provided, the locale defaults to "en-US"
.The locale will change how the time is displayed to the user with the display format. The locale will also affect the output format if a custom format is used.The default display format is the standard time format in the specified locale, for example:Locale | Default format example |
---|---|
en-US | 3:20 PM |
ar-SY | ٣:٢٠ م |
de-DE | 15:20 |
zh-CN | 下午3:20 |
Select fields let users choose from predefined options. You must provide an array of validortype: ["select", { allowCustom: <boolean> }]
selectOptions
, where the label
is shown in the UI; the value
is saved in the output.Select fields are treated differently during the import process. Expand the section below to learn more.selectOptions
can be overridden for individual cells using a row hook. See the Row Hooks documentation for details.alternateMatche
s`, an array of strings. If an input value matches any of these, it will be mapped to that option’s value.
type: "checkbox"
true
or false
).When importing, the following case-insensitive values are considered false: ""
(empty cell), "0"
, "off"
, "n"
, "no"
, "false"
, "disabled"
. All other values are considered true.
type: "email"
Email fields are strings with built-in validation per the HTML5 spec. There are some additional constraints: single domains (such as contact@dromo
, with no TLD) and IP addresses are not allowed in the host portion.Country fields validate values against a list of valid country codes (either ISO 3166 alpha-2 or alpha-3) based on thetype: "country"
format
option. If not specified, “2-letter” is used.Phone number fields can be used to validate phone numbers in many different scenarios.When format istype: "phone-number"
"international"
(default), the field validates full international numbers with country codes, displaying them with spaces (e.g., +1 212 867 5309) but outputting in E.164 (“+33123456789”), unless outputFormatted: true
.With format: "national"
and a country (e.g., "US"
), it validates local numbers and displays them in national format (e.g., (212) 867-5309), outputting digits only unless outputFormatted: true.Use format: "both"
with a country to accept both international and national formats. All values are displayed and output in international format.Social security number fields can be used to validate US SSNs. The input can be either 9 digits or 11 digits with dashes. The output is a string of digits, optionally including dashes iftype: "ssn"
outputDash
is set to true
. This (obviously) does not validate the actual SSN.Domain fields validate input as a proper domain name (no paths, queries, or fragments), checking subdomains based on thetype: "domain"
allowSubdomains
option, which defaults to true.If you need a field that accepts paths and query params, consider using an URL field.URL fields can be used to validate and normalize all URLs. You can optionally specify a list of accepted protocols (liketype: "url"
https
) and/or domains (like dromo.io
).The value of the URL will be normalized to strip extra dashes and relative path references. For example, an input of https:///dromo.io/foo/../bar is a valid URL, but will be normalized to the value https://dromo.io/bar.
type: "us-state-territory"
US State/Territory fields can be used to validate values against standard US state and territory postal codes. The input can be both 2-letter ISO state/territory codes or 4-letter codes. e.g. AL
or US-AL
. The output is a 2-letter code.US Zipcode fields can be used to validate values against US zip codes, either the 5-digit or 9-digit “ZIP+4” variant, specified by thetype: "us-zip-code"
format
option.5-digit
format accepts 5 or 9 digit values (with or without dashes), but truncates 9-digit inputs to the first 5 digits. Shorter values are left-padded with zeros (e.g., 342
→ 00342
).9-digit
format does not accept 5 digit values. It will accept only 9 digits, with our without dashes.
type: "uuid"
validate
function provided by uuid
library. If version
is provided, it will also check the UUID version using the getVersion
from the uuid
library.