Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPAddress validator does not respect not_empty, if_missing or if_invalid_python #120

Open
NucleaPeon opened this issue Sep 16, 2016 · 0 comments

Comments

@NucleaPeon
Copy link

NucleaPeon commented Sep 16, 2016

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant