class OptionalIfFieldEqualTo(wtf.validators.Optional):

    def __init__(self, other_field_name, value, *args, **kwargs):
        self.other_field_name = other_field_name
self.value = value
super(OptionalIfFieldEqualTo, self).__init__(*args, **kwargs)

def __call__(self, form, field):
    other_field = form._fields.get(self.other_field_name)
if other_field is None:
    raise Exception('no field named "%s" in form' % self.other_field_name)
if other_field.data == self.value:
    super(OptionalIfFieldEqualTo, self).__call__(form, field)
Как сделать поле условно необязательным в WTForms?