Skip to content

Commit

Permalink
Merge ef9cb9a into e6cefaf
Browse files Browse the repository at this point in the history
  • Loading branch information
omarryhan committed Apr 21, 2020
2 parents e6cefaf + ef9cb9a commit 86d8350
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/wtforms/form.py
Expand Up @@ -279,15 +279,17 @@ def __delattr__(self, name):
else:
super().__delattr__(name)

def validate(self):
"""
Validates the form by calling `validate` on each field, passing any
extra `Form.validate_<fieldname>` validators to the field validator.
"""
def _get_extras(self):
extra = {}
for name in self._fields:
inline = getattr(self.__class__, "validate_%s" % name, None)
if inline is not None:
extra[name] = [inline]
return extra

return super().validate(extra)
def validate(self):
"""
Validates the form by calling `validate` on each field, passing any
extra `Form.validate_<fieldname>` validators to the field validator.
"""
return super().validate(self._get_extras())

0 comments on commit 86d8350

Please sign in to comment.