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

GroupedQuerySelectMultipleField validator is broken #121

Closed
superosku opened this issue Aug 28, 2017 · 0 comments
Closed

GroupedQuerySelectMultipleField validator is broken #121

superosku opened this issue Aug 28, 2017 · 0 comments

Comments

@superosku
Copy link
Contributor

GroupedQuerySelectMultipleField field validator does not raise Not a valid choice ValidationError if it is called with extra data that does not appear in what the fields query or query_factory returns.

This happens because the field has following pre_validate method:

    def pre_validate(self, form):
        if self._invalid_formdata:
            from pdb import set_trace; set_trace()
            raise ValidationError(self.gettext('Not a valid choice'))
        elif self.data:
            obj_list = list(x[1] for x in self._get_object_list())
            for v in self.data:
                if v not in obj_list:
                    raise ValidationError(self.gettext('Not a valid choice'))

On the first line this method checks if self._invalid_formdata but _invalid_formdata is only set at when getting the data property. That property does not get called before 6th line of this method.

This causes the validation to success incorrectly.

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