I have a schema with an IPAddress validator. The IP address is optional so the validation cannot raise errors when the ip field is missing. However, options that are supposed to allow fields to accept empty values do not work with this validator type.
Schema:
class IPTest(formencode.Schema):
ip = validators.IPAddress(not_empty=False, if_missing=None, if_invalid_python=None)
Action:
IPTest().to_python({"ip": "asdf"})
Expected Result: {"ip": None}
Actual Result:
>>> IPTest().to_python({"ip": "asdf"})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/formencode/api.py", line 476, in to_python
value = tp(value, state)
File "/usr/local/lib/python3.4/dist-packages/formencode/schema.py", line 217, in _convert_to_python
value_dict, state, error_dict=errors)
formencode.api.Invalid: ip: Please enter a valid IP address (a.b.c.d)
I have a schema with an IPAddress validator. The IP address is optional so the validation cannot raise errors when the ip field is missing. However, options that are supposed to allow fields to accept empty values do not work with this validator type.
Schema:
Action:
Expected Result:
{"ip": None}Actual Result: