Express CSV Logo

Datetime

Datetime fields use x.datetime() for combined date and time values.

x.datetime().label("Created At")

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. They do not change the output object key.

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., { createdAt: 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.

output

Sets the output format template.

.output(template: string)

  • template sets the output format template, e.g., "yyyy-MM-dd HH:mm:ss" or "MMM d, yyyy h:mm a".

allowOffset

Allows timezone offsets in the input.

.allowOffset(options?: { message?: string })

  • message overrides the validation error text, e.g., "Timezone offsets are required".