from flask_wtf import Form


class BaseForm(Form):
    class Meta:
        def bind_field(self, form, unbound_field, options):
            filters = unbound_field.kwargs.get('filters', [])
            filters.append(strip_filter)
            return unbound_field.bind(form=form, filters=filters, **options)


def strip_filter(value):
    if not value or not hasattr(value, 'strip'):
        return value
    return value.strip()

from flask_wtf import FlaskForm


class BaseForm(FlaskForm):
    class Meta:
        def bind_field(self, form, unbound_field, options):
            filters = unbound_field.kwargs.get('filters', [])
            filters.append(strip_filter)
            return unbound_field.bind(form=form, filters=filters, **options)


def strip_filter(value):
    if not value or not hasattr(value, 'strip'):
        return value
    return value.strip()

switch to FlaskForm as Form will be deprecated in FlaskWTF 1.0