Miscellany
public text v1 · immutableclass Optional(object):
"""
Allows empty input and stops the validation chain from continuing.
If input is empty, also removes prior errors (such as processing errors)
from the field.
"""
field_flags = ('optional', )
def __call__(self, form, field):
if not field.raw_data or isinstance(field.raw_data[0], basestring) and not field.raw_data[0].strip():
field.errors[:] = []
raise StopValidation()