Skip to content

Commit b241698

Browse files
committed
BugFix: recursive field validation
1 parent b832957 commit b241698

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.2.8
2+
=====
3+
4+
* BugFix: recursive field validation
5+
16
1.2.7
27
=====
38

pyArango/collection.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,24 +335,29 @@ def _getValidators(cls, fieldName) :
335335
return None
336336
return v
337337

338-
validators = _getValidators(cls, fieldName)
338+
field = _getValidators(cls, fieldName)
339339

340-
if validators is None :
340+
if field is None :
341341
if not cls._validation["allow_foreign_fields"] :
342342
raise SchemaViolation(cls, fieldName)
343343
else :
344-
return validators.validate(value)
344+
return field.validate(value)
345345

346346
@classmethod
347347
def validateDct(cls, dct) :
348348
"validates a dictionary. The dictionary must be defined such as {field: value}. If the validation is unsuccefull, raises an InvalidDocument"
349-
def _validate(dct, res) :
349+
def _validate(dct, res, parentsStr="") :
350350
for k, v in dct.items() :
351+
if len(parentsStr) == 0 :
352+
ps = k
353+
else :
354+
ps = "%s.%s" % (parentsStr, k)
355+
351356
if type(v) is dict :
352-
_validate(v, res)
357+
_validate(v, res, ps)
353358
elif k not in cls.arangoPrivates :
354359
try :
355-
cls.validateField(k, v)
360+
cls.validateField(ps, v)
356361
except (ValidationError, SchemaViolation) as e:
357362
res[k] = str(e)
358363

0 commit comments

Comments
 (0)