Open
Description
def MyMappingValidator(node, value):
raise colander.Invalid(node['foo'], 'value must be less than 50')
schema = colander.SchemaNode(
colander.Sequence(),
colander.SchemaNode(
colander.Mapping(),
colander.SchemaNode(colander.Integer(), name='foo'),
validator=MyMappingValidator,
),
)
schema.deserialize([{'foo': 100}])
Results in the following traceback:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/michael/work/scratch/eggs/colander-1.0b1-py2.7.egg/colander/__init__.py", line 1917, in deserialize
appstruct = self.typ.deserialize(self, cstruct)
File "/Users/michael/scratch/eggs/colander-1.0b1-py2.7.egg/colander/__init__.py", line 988, in deserialize
return self._impl(node, cstruct, callback, accept_scalar)
File "/Users/michael/scratch/eggs/colander-1.0b1-py2.7.egg/colander/__init__.py", line 930, in _impl
raise error
Invalid: {'0': 'value must be less than 50'}
Whereas if I put the validator on the node itself, the error message path properly indicates {'0.foo': 'value must be less than 50'}
. Please ignore the simplicity of the example, the actual use case is for a validator that checks the subnodes based on other subnodes and the error messages do not come out correct right now.
Metadata
Metadata
Assignees
Labels
No labels