Function parseTabularData
- parseTabularData<Fields extends TabularFields>(
fields: Fields,
data: TabularRow[],
options?: { maxErrors?: number },
):
| { errors: TabularImportError[]; rows?: undefined }
| { errors?: undefined; rows: OutputRowForFields<Fields>[] }Type Parameters
- Fields extends TabularFields
a record mapping output property names to
TabularFielddescriptors
Parameters
- fields: Fields
field configuration (header names, types, validations)
- data: TabularRow[]
tabular input where
data[0]is the header row Optionaloptions: { maxErrors?: number }OptionalmaxErrors?: numbermaximum errors to collect before truncating
Returns
| { errors: TabularImportError[]; rows?: undefined }
| { errors?: undefined; rows: OutputRowForFields<Fields>[] }either
{ rows: OutputRowForFields<Fields>[] }on success or{ errors: TabularImportError[] }on failureExample:
const result = parseTabularData({
code: { header: 'Program code' },
active: { header: 'Active', type: 'boolean', optional: true }
} as const, rows);
// result.rows -> [{ code: 'EMM', active: true }, ...] OR { errors: [...] } - Fields extends TabularFields
Parse tabular input into typed rows according to
fields.