You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to surface validation errors to my users when they upload a .csv file that does not conform to the rules defined for that template.
The current implementation of validation errors are okay for now, but there are a few use cases that I would like to be considered:
Allow users to customize error messages for a particular error type. This should also incorporate string interpolation for things like row, column, field_name, constraint key, and constraint value so users could build the appropriate message. It would be nice if all of this information was available in the TableSchemaError class. So that the caller could use that information to organize errors into logical clusters. This was my attempt at organizing errors by field but it's pretty hacky (and doesn't work at all for the unique constraint because of bullet point 3)
Support for multiple languages. It would be nice if the tableschema library used IDs rather than strings so it would be easier to dynamically pick a message based on the users I18n an l10n preferences.
Increased consistency to the data available for an error. For example, the unique constraint lacks a columnName. I can submit a pr for this if you think it makes sense.
// Check uniqueif(cast){for(const[indexes,cache]ofObject.entries(uniqueFieldsCache)){constsplitIndexes=indexes.split(',').map(index=>parseInt(index,10))constvalues=row.filter((value,index)=>splitIndexes.includes(index))if(!values.every(value=>value===null)){if(cache.data.has(values.toString())){constcolumnNumber=this._headers.indexOf(cache.name)// <------- I considered adding if(columnNumber>-1)error.columnNumber=columnNumber// <----- to set the missing columnconsterror=newTableSchemaError(`Row ${rowNumber} has an unique constraint `+`violation in column "${cache.name}"`)error.rowNumber=rowNumberif(forceCast)returnerrorthrowerror}cache.data.add(values.toString())}}}
The text was updated successfully, but these errors were encountered:
I am trying to surface validation errors to my users when they upload a .csv file that does not conform to the rules defined for that template.
The current implementation of validation errors are okay for now, but there are a few use cases that I would like to be considered:
Support for multiple languages. It would be nice if the tableschema library used IDs rather than strings so it would be easier to dynamically pick a message based on the users I18n an l10n preferences.
Increased consistency to the data available for an error. For example, the unique constraint lacks a columnName. I can submit a pr for this if you think it makes sense.
The text was updated successfully, but these errors were encountered: