Skip to content

Handling of validated vs. error rows should be optional for each header #92

@nimrodyanai

Description

@nimrodyanai

In case the CSV file needs to be used for something after validation, it would be good to have a way of getting all the validated rows separately from the error rows. That way, the code can continue running for the validated rows, while the non-validated rows can be handled separately without having to stop the entire code.

For each header, there needs to be an option that will say if an error in validation for that header will cause the row to be removed from the validated rows.

For example:
{
name: 'Email',
inputName: 'email',
removeIfNotValid: true,
unique: true,
uniqueError: function (headerName) {
return ${headerName} is not unique
},
validate: function(email) {
return isEmailValid(email)
},
validateError: function (headerName, rowNumber, columnNumber) {
return ${headerName} is not valid in the ${rowNumber} row / ${columnNumber} column
}
}

The removeIfNotValid will indicate whether or not a row should be removed from the Valid object.

The "csvData" object will then contain 3 objects instead of 2: inValidMessages, data and validData, with the last containing ONLY the rows that have been validated correctly.
Another option is to have yet another object: invalidData, which will contain the original rows that have not validated correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions