You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, while challenging our API with random input we noticed that the Email validator wasn't failing with a ValidationError when we give it the wrong input:
em = fe.validators.Email()
em.to_python(45)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-19-4dfaedfd72a0> in <module>()
----> 1 em.to_python(45)
~/.pyenv/versions/3.6.5/envs/cmp/lib/python3.6/site-packages/formencode/api.py in to_python(self, value, state)
--> 475 value = tp(value, state)
~/.pyenv/versions/3.6.5/envs/cmp/lib/python3.6/site-packages/formencode/validators.py in _convert_to_python(self, value, state)
-> 1390 return value.strip()
AttributeError: 'int' object has no attribute 'strip'
Before starting to work on this, I was wondering if there is any reason that validators.Email inherit from FancyValidator and not from validators.String? In fact, changing this would fix this bug
The text was updated successfully, but these errors were encountered:
You might try putting it into an All() validator in the meantime. I had to put email first, then unicodestring (All() seems to run from the last validator to the first?)
allem = All(Email(), UnicodeString())
>>> allem.to_python(45)
Then you will get a traceback:
Traceback (most recent call last):
File "/home/vagrant/meso_venv/lib/python3.7/site-packages/formencode/validators.py", line 1347, in _validate_python
username, domain = splitted
ValueError: not enough values to unpack (expected 2, got 1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vagrant/meso_venv/lib/python3.7/site-packages/formencode/api.py", line 475, in to_python
value = tp(value, state)
File "/home/vagrant/meso_venv/lib/python3.7/site-packages/formencode/compound.py", line 65, in _convert_to_python
to_python)
File "/home/vagrant/meso_venv/lib/python3.7/site-packages/formencode/compound.py", line 175, in _attempt_convert
value = validate(validator, value, state)
File "/home/vagrant/meso_venv/lib/python3.7/site-packages/formencode/compound.py", line 16, in to_python
return validator.to_python(value, state)
File "/home/vagrant/meso_venv/lib/python3.7/site-packages/formencode/api.py", line 478, in to_python
vp(value, state)
File "/home/vagrant/meso_venv/lib/python3.7/site-packages/formencode/validators.py", line 1349, in _validate_python
raise Invalid(self.message('noAt', state), value, state)
formencode.api.Invalid: An email address must contain a single @
Hi, while challenging our API with random input we noticed that the Email validator wasn't failing with a ValidationError when we give it the wrong input:
Before starting to work on this, I was wondering if there is any reason that validators.Email inherit from FancyValidator and not from validators.String? In fact, changing this would fix this bug
The text was updated successfully, but these errors were encountered: