Skip to content

Instantly share code, notes, and snippets.

@tristan2077
Created August 1, 2018 03:30
Show Gist options
  • Save tristan2077/88ed57450e8cfc67312ac31afc2bbdf5 to your computer and use it in GitHub Desktop.
Save tristan2077/88ed57450e8cfc67312ac31afc2bbdf5 to your computer and use it in GitHub Desktop.
flask_gist
def validate(self):
"""
Validates the form by calling `validate` on each field, passing any
extra `Form.validate_<fieldname>` validators to the field validator.
"""
extra = {}
for name in self._fields:
inline = getattr(self.__class__, 'validate_%s' % name, None)
if inline is not None:
extra[name] = [inline]
return super(Form, self).validate(extra)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment