|
@@ -39,13 +39,19 @@ class EmField(EmComponent):
|
39
|
39
|
self.fieldtype = fieldtype
|
40
|
40
|
self._fieldtype_args = kwargs
|
41
|
41
|
self._fieldtype_args.update({'nullable' : nullable, 'default' : default, 'uniq' : uniq})
|
42
|
|
- self._fieldtype_instance = self._fieldtype_cls(**self._fieldtype_args)
|
|
42
|
+ try:
|
|
43
|
+ fieldtype_instance = self._fieldtype_cls(**self._fieldtype_args)
|
|
44
|
+ except AttributeError as e:
|
|
45
|
+ raise AttributeError("Error will instanciating fieldtype : %s"%e)
|
|
46
|
+
|
|
47
|
+ if not fieldtype_instance.check(default):
|
|
48
|
+ raise TypeError("Default value ('%s') is not valid given the fieldtype '%s'"%(default, fieldtype))
|
43
|
49
|
|
44
|
50
|
|
45
|
51
|
self.nullable = nullable
|
46
|
52
|
self.default = default
|
47
|
53
|
self.uniq = uniq
|
48
|
|
-
|
|
54
|
+
|
49
|
55
|
for kname, kval in kwargs.items():
|
50
|
56
|
setattr(self, kname, kval)
|
51
|
57
|
|