Skip to content

Commit

Permalink
Make newline a property in CsvValidationOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jacomorr22 committed Jan 16, 2025
1 parent 648beef commit dfb978e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,8 @@ export async function validateCsv(
}

return new Promise((resolve, reject) => {
Papa.parse(input, {
const config = {
header: false,
newline: "\n",
// chunkSize: 64 * 1024,
beforeFirstChunk: (chunk) => {
return removeBOM(chunk)
},
Expand All @@ -197,6 +195,12 @@ export async function validateCsv(
},
complete: () => handleParseEnd(resolve),
error: (error: Error) => reject(error),
})
};

if (options.newline) {
config.newline = options.newline;
}

Papa.parse(input, config)
})
}
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ export interface CsvValidatorVersion {

export interface CsvValidationOptions {
maxErrors?: number
newline?: string
onValueCallback?: (value: { [key: string]: string }) => void
}

export interface JsonValidatorOptions {
maxErrors?: number
newline?: string
onValueCallback?: (
val: JsonTypes.JsonPrimitive | JsonTypes.JsonStruct
) => void
Expand Down

0 comments on commit dfb978e

Please sign in to comment.