Express CSV Logo

Select

Select fields use x.select(options) for a single selection from a fixed list. Each option has a label (shown to the user), a value (returned in data), and an optional alsoMatches array for alternate CSV values.

x.select([
  { label: "Admin", value: "admin" },
  { label: "Editor", value: "editor" },
  { label: "Viewer", value: "viewer" },
]).label("Role")

columnNameAliases

Adds alternate CSV header names for this field.

.columnNameAliases(aliases: string[])

  • aliases lists header names that should map to this schema key.
  • Aliases are used during column matching alongside the field key and label. Use option alsoMatches for alternate cell values.

label

Sets the user-facing label shown in the importer.

.label(text: string)

  • text sets the label text.

description

Sets help text shown below the field.

.description(text: string)

  • text sets the description text.

optional

Allows the field to be empty.

.optional()

  • Empty optional values are delivered as null.
  • The row object still includes the field key, e.g., { role: null }.

default

Available after .optional().

.default(defaultValue: unknown | (() => unknown | Promise<unknown>))

  • defaultValue can be a static value or a function used when the field is empty.
  • Defaults apply to missing values, null, empty strings, and whitespace-only strings.
  • When a default is used, it is returned directly instead of validating or refining the empty value.

caseSensitive

Controls whether option matching is case-sensitive.

.caseSensitive(enabled?: boolean)

  • enabled enables or disables case-sensitive matching.