1717Column: Use for strings & general purpose
1818IntColumn, FloatColumn: Cast to int/float datatypes and apply number logic like min_value, max_value
1919DateColumn, DateTimeColumn: Cast to date/time datatypes and apply calendar logic like default timezone
20-
21- TODOs:
22- * Probably the default column and the other columns should both inherit from a BaseColumn, so we can
23- have fields like 'blank' on Column but not on IntColumn
20+ BooleanColumn: cast 1, 0, T, F, yes, no, TRUE, FALSE etc to python True and False values.
2421
2522"""
2623
@@ -83,7 +80,7 @@ def __init__(self,
8380 self .use_exception = Column .ON_ERROR_VALUES [on_error ]
8481
8582 if self .null is False and self .default is not None :
86- raise Exception (f"Column { self .name } defined to error on null values, but also provides a non-null default" )
83+ raise PhaserError (f"Column { self .name } defined to error on null values, but also provides a non-null default" )
8784
8885 def check_required (self , data_headers ):
8986 """
@@ -128,7 +125,7 @@ def check_value(self, value):
128125 """ Raises chosen exception type if something is wrong with a value in the column.
129126 One can override this to use a different exception or check value in a different way
130127 (don't forget to call super().check_value() """
131- if not self .blank and not value : # Python boolean casting returns false if string is empty
128+ if not self .blank and not value . strip () : # Python boolean casting returns false if string is empty
132129 raise self .use_exception (f"Column `{ self .name } ' had blank value" )
133130 if self .allowed_values and not (value in self .allowed_values ):
134131 raise self .use_exception (f"Column '{ self .name } ' had value { value } not found in allowed values" )
@@ -215,7 +212,6 @@ def __init__(self,
215212 name ,
216213 required = True ,
217214 null = True ,
218- blank = True ,
219215 default = None ,
220216 fix_value_fn = None ,
221217 rename = None ,
@@ -227,7 +223,7 @@ def __init__(self,
227223 super ().__init__ (name ,
228224 required = required ,
229225 null = null ,
230- blank = blank ,
226+ blank = True , # Ignores this column - only null=T/F matters
231227 default = default ,
232228 fix_value_fn = fix_value_fn ,
233229 rename = rename ,
@@ -289,7 +285,6 @@ def __init__(self,
289285 name ,
290286 required = True ,
291287 null = True ,
292- blank = True ,
293288 default = None ,
294289 fix_value_fn = None ,
295290 rename = None ,
@@ -303,7 +298,7 @@ def __init__(self,
303298 super ().__init__ (name ,
304299 required = required ,
305300 null = null ,
306- blank = blank ,
301+ blank = True , # Ignores this param - only null=T/F matters
307302 default = default ,
308303 fix_value_fn = fix_value_fn ,
309304 rename = rename ,
0 commit comments