In [3]: class TestTarget2(Schema):
...: test = f.String()
...:
...: class TestTargetPoly(PolySchema):
...: _type = f.String()
...: __poly_on__ = _type
...:
...: class TestTarget(TestTargetPoly):
...: test = f.Schema(TestTarget2)
...: __poly_id__ = 'test'
...:
...: class TestSource(Schema):
...: target = f.Schema(TestTargetPoly)
In [4]: TestSource().validate({'target': {'_type': 'test', 'test': None}})
---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
~/.virtualenvs/docgen/local/lib/python3.6/site-packages/ciri/fields.py in validate(self, value)
365 try:
--> 366 return schema.validate(value, exclude=self.exclude, whitelist=self.whitelist, tags=self.tags, **schema._schema._validation_opts)
367 except ValidationError as e:
~/.virtualenvs/docgen/local/lib/python3.6/site-packages/ciri/core.py in validate(self, data, *args, **kwargs)
849 schema = self.__poly_mapping__.get(id_)(*self.__poly_args__, **self.__poly_kwargs__)
--> 850 return schema.validate(data, *args, **kwargs)
851
~/.virtualenvs/docgen/local/lib/python3.6/site-packages/ciri/core.py in validate(self, data, halt_on_error, key_cache, exclude, whitelist, tags, context)
631 if self._config.raise_errors and errors:
--> 632 raise ValidationError(self)
633 return valid
ValidationError: <__main__.TestTarget object at 0x7f59e612feb8>
During handling of the above exception, another exception occurred:
FieldValidationError Traceback (most recent call last)
~/.virtualenvs/docgen/local/lib/python3.6/site-packages/ciri/core.py in _iterate(self, fields, elements, data, validation_opts, parent, do_serialize, exclude, do_deserialize, do_validate, whitelist, tags)
445 if do_validate:
--> 446 sub = klass_value = valid[key] = parent._subfields[key].validate(sub)
447 if do_serialize:
~/.virtualenvs/docgen/local/lib/python3.6/site-packages/ciri/fields.py in validate(self, value)
367 except ValidationError as e:
--> 368 raise FieldValidationError(FieldError(self, 'invalid', errors=schema._raw_errors))
369
FieldValidationError: <ciri.fields.FieldError object at 0x7f59e612ff60>
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-4-a26d5cd6636a> in <module>
----> 1 TestSource().validate({'target': {'_type': 'test', 'test': None}})
~/.virtualenvs/docgen/local/lib/python3.6/site-packages/ciri/core.py in validate(self, data, halt_on_error, key_cache, exclude, whitelist, tags, context)
622 self._validation_opts, parent=self,
623 do_validate=True, exclude=exclude,
--> 624 whitelist=whitelist, tags=tags)
625
626 if hasattr(self._schema_callables, 'post_validate'):
~/.virtualenvs/docgen/local/lib/python3.6/site-packages/ciri/core.py in _iterate(self, fields, elements, data, validation_opts, parent, do_serialize, exclude, do_deserialize, do_validate, whitelist, tags)
450 sub = klass_value = valid[key] = parent._subfields[key].deserialize(sub)
451 except ValidationError as _e:
--> 452 errors[key] = FieldError(parent._subfields[key], 'invalid', errors=field._raw_errors)
453 continue
454
AttributeError: 'TestTarget' object has no attribute '_raw_errors'
Here's an example: