Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chained validators not working as documented #94

Open
benbeanfield opened this issue Sep 10, 2015 · 2 comments
Open

Chained validators not working as documented #94

benbeanfield opened this issue Sep 10, 2015 · 2 comments

Comments

@benbeanfield
Copy link

From the docs:

chained_validators will also allow for multiple validators to fail and report to the error_dict

Running the following snippet should result in two errors, but only one is produced:

>>> from formencode import Invalid, Schema
>>> from formencode.validators import RequireIfMissing
>>> 
>>> class A(Schema):
...     chained_validators = [
...         RequireIfMissing('foo', missing='far'), 
...         RequireIfMissing('moo', missing='mar')]
... 
>>> 
>>> try:
...     A.to_python({})
... except Invalid as e:
...     print e.error_dict
... 
{'foo': Invalid(u'Please enter a value', None, None, None, None)}```
@Cito
Copy link
Member

Cito commented Sep 13, 2015

This works only for validators that define a validate_partial() method and have validate_partial_form=True, which is the case only for FieldsMatch and the CreditCardValidators; so it does not work with RequireIfMissing and RequireIfMatching.

This should in fact be mentioned in the docs, but maybe we should also add partial_validate() methods to some more validators?

@benbeanfield
Copy link
Author

Thanks for the explanation, Cito.

Yep, I'd think that any validator that could conceivably implement partial_validate() would do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants