parseTabularData | WebHare Platform SDK
WebHare Platform SDK
    Preparing search index...
    • Parse tabular input into typed rows according to fields.

      Type Parameters

      • Fields extends TabularFields

        a record mapping output property names to TabularField descriptors

      Parameters

      • fields: Fields

        field configuration (header names, types, validations)

      • data: TabularRow[]

        tabular input where data[0] is the header row

      • Optionaloptions: { maxErrors?: number }
        • OptionalmaxErrors?: number

          maximum 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 failure

      Example:

      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: [...] }