Dromo’s field types define how a field accepts, transforms, validates, and outputs data. They ensure consistent data types across a field (e.g., number for numeric values, string for text). Field types cover categories like numbers, text, dates, and times.

Selecting the Best Type

By default, if you don’t specify a type for a field, it uses the string type. For example, below, we create a field for collecting email addresses:
const fields = [
  {
    label: 'Email Address',
    key: 'emailAddress'
  }
];

const settings = {
  importIdentifier: 'Field types example'
};

const user = {
  id: '12345'
};

const dromo = new DromoUploader('FRONTEND_API_KEY', fields, settings, user);
Because we didn’t specify a type in the above “Email Address” field, it uses the default string type. However, if we update the “Email address” field to use the email type, that field gains the advantage of Dromo’s built-in email address validation:
const fields = [
  {
    label: 'Email',
    key: 'email',
    type: 'email'
  }
];
Selecting the ideal type for each field is essential to honing your Dromo workflow. See all field types.

Configuring Field Types

Certain field types offer different configuration options, enabling you to customize how data is validated, displayed to the user, and output. For example, we want a field that tracks prices in USD. We can add a “Price” field using the “usd” preset:
const fields = [
  {
    label: 'Price',
    key: 'price',
    type: ['number', { preset: 'usd' }]
  }
];
 
The “usd” preset ensures that this number field parses, validates, displays, and outputs values in dollars. Therefore, if a user attempts to insert a value that can’t be parsed into USD (i.e., another currency), Dromo throws a validation error: Validation error for inputting invalid currency
For numbers (and a few other field types) the display format is not what the field outputs. If you want to change how a field is output, the outputFormat configuration option enables you to do so. For example, if you want to convert a number into USD, you can use the “usd” preset alongside an outputFormat option.