`inValidMessages` needs to be more descriptive
hirenchauhan2 opened this issue · 0 comments
hirenchauhan2 commented
Currently the inValidMessages
is just a strings array with no addition info. It's gets pretty messy to put formatted strings to identify row with error if we want to do complex tasks.
Context
I'm working on CSV import tool, and need to validate CSV files on client side. This tool will show the parsed data in a table. I want to add the error message on the table's row and highlight it and allow user to edit the data in-place. To do that we need to have an index of that row/column to quickly mark it as an errored record in the table.
Proposed suggestion
We should have an error object with at least these properties to start with:
interface RowValidationError {
rowIndex?: number;
columnIndex?: number;
message: string; // this will be populated by the config validation functions like requiredError, uniqueError, uniqueError, etc.
}
interface ParsedResults<Row = any, Error = RowValidationError> {
/** Array of parsed CSV entries */
data: Row[];
/** List of validation error messages */
inValidMessages: Error[];
}
update
- made
rowIndex
,columnIndex
fields optional, as in some scenarios they may not have these details. e.g. top level file error, etc.