Andrea Riciputi
2009-03-06 15:59:13 UTC
Hi,
I'm still having some issues with chained validators. Despite what
mentioned in the documentation, chained_validators **doesn't** always
allow for multiple validators to fail.
In fact the example in the documentation works as expected, but the
following one doesn't:
class Foo(Schema):
filter_extra_fields = True
allow_extra_fields = True
a = String()
b = String()
c = String()
d = String()
chained_validators = [
RequireIfPresent('a', present='b'),
RequireIfPresent('c', present='d'),
]
pass
foo = Foo()
try:
foo.to_python({'a':'', 'b':'bb', 'c':'', 'd':'dd'})
except fe.Invalid, err:
print err.error_dict
{'a': Invalid(u'Please enter a value',)}
whilst I'd have expected two error messages since both 'a' and 'c'
fields are missing! Could you explain me why this happens, and how I
can get all the chained validators actually evaluated?
Cheers,
Andrea
I'm still having some issues with chained validators. Despite what
mentioned in the documentation, chained_validators **doesn't** always
allow for multiple validators to fail.
In fact the example in the documentation works as expected, but the
following one doesn't:
class Foo(Schema):
filter_extra_fields = True
allow_extra_fields = True
a = String()
b = String()
c = String()
d = String()
chained_validators = [
RequireIfPresent('a', present='b'),
RequireIfPresent('c', present='d'),
]
pass
foo = Foo()
try:
foo.to_python({'a':'', 'b':'bb', 'c':'', 'd':'dd'})
except fe.Invalid, err:
print err.error_dict
{'a': Invalid(u'Please enter a value',)}
whilst I'd have expected two error messages since both 'a' and 'c'
fields are missing! Could you explain me why this happens, and how I
can get all the chained validators actually evaluated?
Cheers,
Andrea