You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GroupedQuerySelectMultipleField field validator does not raise Not a valid choiceValidationError 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.
The text was updated successfully, but these errors were encountered:
superosku
added a commit
to superosku/wtforms-alchemy
that referenced
this issue
Aug 29, 2017
GroupedQuerySelectMultipleField
field validator does not raiseNot a valid choice
ValidationError
if it is called with extra data that does not appear in what the fieldsquery
orquery_factory
returns.This happens because the field has following
pre_validate
method:On the first line this method checks
if self._invalid_formdata
but_invalid_formdata
is only set at when getting thedata
property. That property does not get called before 6th line of this method.This causes the validation to success incorrectly.
The text was updated successfully, but these errors were encountered: