I have a form field which is not required, but when it is submitted with data, I want the data to be validated. The problem is, I get the validator triggering when the form is submitted with no value in that field. I want it to wait until there's data in there to validate it and ignore it if blank. I thought I could get this behavior with required=False and then using requires= validators, but it is failing the validation every time when there's no data in the field. How do you get it to validate data that's present and ignore blanks?
The field in question is in the db.py as follows:
Field('special_code1', 'string', length=200, required=False, label='Special Code 1',
requires=[IS_LENGTH(maxsize=200),
IS_MATCH('^[a-zA-Z0-9\s\#\.\$\-\_]+$', error_message='Character Not Allowed.')]
),
There are no other controllers acting on this data, and no combination of anything I try above gets me what I want.