catamphetamine / read-excel-file

Read *.xlsx files in a browser or Node.js. Parse to JSON with a strict schema.
https://catamphetamine.gitlab.io/read-excel-file/
MIT License
301 stars 52 forks source link

parse validation using async function #57

Closed llermaly closed 5 years ago

llermaly commented 5 years ago

Hello, is it possible to validate rows using an async function (like consulting database) and what is the best way to do it? I'm trying without success.

    parse(value) {
      const exists = findInDatabase(value) //async
      if (!exists) {
        throw new Error("Error");
      }
      return value;
    }
catamphetamine commented 5 years ago

Hello, is it possible to validate rows using an async function (like consulting database)

No.

what is the best way to do it?

Nothing special about that: first read the data from a file and then validate it as a separate function call.