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

Regexp support #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Regexp support #72

wants to merge 2 commits into from

Conversation

fuhrysteve
Copy link
Owner

Resolves conflicts from #24

dict: A, possibly, new JSON Schema that has been post processed and
altered.
"""
if not isinstance(field, fields.String):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend raising an UnsupportedValueError here as I did for other validators. marshmallow will fail on non-strings anyway:

>>> from marshmallow import fields
>>> from marshmallow.validate import Regexp
>>> f = fields.Integer(validate=Regexp(".*"))
>>> f.deserialize(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lynx/projects/marshmallow-jsonschema/.venv/lib/python3.7/site-packages/marshmallow/fields.py", line 301, in deserialize
    self._validate(output)
  File "/home/lynx/projects/marshmallow-jsonschema/.venv/lib/python3.7/site-packages/marshmallow/fields.py", line 224, in _validate
    r = validator(value)
  File "/home/lynx/projects/marshmallow-jsonschema/.venv/lib/python3.7/site-packages/marshmallow/validate.py", line 362, in __call__
    if self.regex.match(value) is None:
TypeError: expected string or bytes-like object

Custom fields have to be handled with care though as they are not required to be an instance of fields.String. Though they are not supported yet, there is an attempt in #22.

@atmo
Copy link
Contributor

atmo commented Jul 22, 2019

Hi @fuhrysteve ! Could you please resolve the conflicts in this PR? It would be great to have it merged into master.

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

Successfully merging this pull request may close these issues.

2 participants