Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await new Promise((resolve, reject) => {
csv.parseString(fileContent, { headers: false, trim: true })
.validate((row) => {
// Invalid column count
if (row.length !== 2) {
hasInvalidNumberOfColumns = true
}
// Invalid integers
if (row && row[0] && row[1] &&
(row[0] < config.CHECK_FORM_MIN_INTEGER || row[0] > config.CHECK_FORM_MAX_INTEGER ||
row[1] < config.CHECK_FORM_MIN_INTEGER || row[1] > config.CHECK_FORM_MAX_INTEGER)) {
hasInvalidIntegers = true
}
// Invalid characters
if ((!row[0] || row[0].match(/[^0-9]/)) || (!row[1] || row[1].match(/[^0-9]/))) {
hasInvalidFileCharacters = true
}
checkFormIntegerCount += row.length
return new Promise((res, rej) => {
const rows:any[] = [];
csv.parseString(csvStr, options)
.on('data', (row: any) => rows.push(row))
.on('error', (err: any) => rej(err))
.on('end', () => res(rows));
});
}