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
Do you have any thoughts on the addition of row validation support, perhaps in the form of a per-Dataset array of callables that are applied to the row on append/insert? I'm unsure if the Dataset is the place for this kind of row data manipulation and validation.
I envisage passing an array of callables on Dataset initialisation which are then applied on row insert. Each callable returns the value to include in the row, or raises an exception. All errors are captured and the Dataset raises InvalidData. For example:
defoneof(val, row):
valid= ['red', 'green', 'blue']
ifvalinvalid:
returnvalraiseInvalidData('Row column %d must be one of %s'% (row.index(val), valid))
data=tablib.Dataset(processors=[int, int, oneof])
data.append(('1', '45', 'green')) ## insert successfullydata.append(('1', '45', 'orange')) ## InvalidData raiseddata.append(('NaN', '45', 'orange')) ## InvalidData raised
I don't want to start any work on this if you have already given it some thought and decided against it.
The text was updated successfully, but these errors were encountered:
I've thought about this before, and the options boiled down to:
Adding Column Types (int, str, regex test)
Adding a Hook System
The plan for the time being is to implement the second option. A hook will be a callable that you'll register to be called when a certain event takes place.
Do you have any thoughts on the addition of row validation support, perhaps in the form of a per-Dataset array of callables that are applied to the row on append/insert? I'm unsure if the Dataset is the place for this kind of row data manipulation and validation.
I envisage passing an array of callables on Dataset initialisation which are then applied on row insert. Each callable returns the value to include in the row, or raises an exception. All errors are captured and the Dataset raises
InvalidData
. For example:I don't want to start any work on this if you have already given it some thought and decided against it.
The text was updated successfully, but these errors were encountered: