Express CSV Logo

Types

Define your import shape with x.row() and field types — labels, validation rules, and TypeScript inference. They are identical across the React and TypeScript SDKs.

Basic Usage

Use x.row() to define your schema:

import { x } from "@expresscsv/react";

const schema = x.row({
  name: x.string().label("Full Name"),
  email: x.string().email().label("Email Address"),
  age: x.number().label("Age").min(18),
  startDate: x.date().label("Start Date"),
  active: x.boolean().label("Active").optional(),
});

Each key becomes a column the user maps to. The field type determines how values are parsed and validated.

Field types

Custom Validation

Use Refine for custom validators with .refine(), .refineBatch(), and suggested fixes.

TypeScript Inference

Use Infer<typeof schema> to extract the row type from your schema:

import { x, type Infer } from "@expresscsv/react";

const schema = x.row({
  name: x.string(),
  age: x.number(),
  active: x.boolean().optional(),
});

type Row = Infer<typeof schema>;
// { name: string; age: number; active?: boolean }

The onData callback receives RecordsChunk<Row> automatically — no manual type annotations needed.

On this page