Skip to content

Regexp support#72

Open
fuhrysteve wants to merge 2 commits intomasterfrom
regexp
Open

Regexp support#72
fuhrysteve wants to merge 2 commits intomasterfrom
regexp

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