|
@@ -85,17 +85,14 @@ class DataHandler(object):
|
85
|
85
|
def _check_data_value(self, value):
|
86
|
86
|
if value is None:
|
87
|
87
|
if not self.nullable:
|
88
|
|
- raise LodelExceptions("None value is forbidden")
|
89
|
|
- raise DataNoneValid("None with a nullable. GOTO CHECK")
|
|
88
|
+ raise LodelExceptions("None value is forbidden for this data field")
|
|
89
|
+ raise DataNoneValid("None with a nullable. This exeption is allowed")
|
90
|
90
|
return value
|
91
|
91
|
|
92
|
92
|
|
93
|
|
- ##@brief calls the data_field defined _check_data_value() method
|
94
|
|
- #@ingroup lodel2_dh_checks
|
95
|
|
- #@warning DO NOT REIMPLEMENT THIS METHOD IN A CUSTOM DATAHANDLER (see
|
96
|
|
- #@ref _construct_data() and @ref lodel2_dh_check_impl)
|
97
|
|
-
|
98
|
|
- #@return tuple (value, Exceptions)
|
|
93
|
+ ##@brief calls the data_field (defined in derived class) _check_data_value() method
|
|
94
|
+ #@param value *
|
|
95
|
+ #@return tuple (value|None, None|error) value can be cast if NoneError
|
99
|
96
|
def check_data_value(self, value):
|
100
|
97
|
try:
|
101
|
98
|
value = self._check_data_value(value)
|
|
@@ -353,7 +350,7 @@ class SingleRef(Reference):
|
353
|
350
|
super().__init__(allowed_classes = allowed_classes)
|
354
|
351
|
|
355
|
352
|
##@brief Check and cast value in appropriate type
|
356
|
|
- #@param value *
|
|
353
|
+ #@param value: *
|
357
|
354
|
#@throw FieldValidationError if value is unappropriate or can not be cast
|
358
|
355
|
#@return value
|
359
|
356
|
def _check_data_value(self, value):
|
|
@@ -389,10 +386,13 @@ class MultipleRef(Reference):
|
389
|
386
|
if self.max_item is not None:
|
390
|
387
|
if self.max_item < len(value):
|
391
|
388
|
raise FieldValidationError("Too many items")
|
392
|
|
- ref_list = []
|
393
|
|
- #Checked reference value one by one .
|
|
389
|
+ error_list = []
|
394
|
390
|
for v in value.items():
|
395
|
|
- ref_list.append(super()._check_data_value(v))
|
|
391
|
+ val, error = super()._check_data_value(v)
|
|
392
|
+ if error:
|
|
393
|
+ error_list.append(val, error)
|
|
394
|
+ if len(error_list) >0:
|
|
395
|
+ raise FieldValidationError("MultipleRef have for error :", error_list)
|
396
|
396
|
return value
|
397
|
397
|
|
398
|
398
|
def construct_data(self, emcomponent, fname, datas, cur_value):
|