From d3a06b848d95ce538eb93eb02a2cd1af1cdfe312 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 19 Apr 2022 21:57:03 +0300 Subject: [PATCH] Update validate.js --- scripts/db/validate.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/db/validate.js b/scripts/db/validate.js index 6e9d9076..663dc49d 100644 --- a/scripts/db/validate.js +++ b/scripts/db/validate.js @@ -34,6 +34,13 @@ async function main() { if (/\s+$/.test(csvString)) return handleError(`Error: empty lines at the end of file not allowed (${filepath})`) + const rows = csvString.split('\r\n') + const headers = rows[0].split(',') + for (let [i, line] of rows.entries()) { + if (line.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/).length !== headers.length) + return handleError(`Error: row ${i + 1} has the wrong number of columns (${filepath})`) + } + const filename = file.getFilename(filepath) let data = await csv .fromString(csvString)