allow_blank works only on load for fields.URL or fields.Email not dump:
from marshmallow import Schema, fields
class Test(Schema):
url = fields.URL(allow_blank=True)
# '2.0.0-dev'
Test().dump({'url': ''})
returns:
MarshalResult(data={u'url': None}, errors={u'url': [u'"" is not a valid URL.']})
I think it should return:
MarshalResult(data={u'url': u''}, errors={})
+1. I think you are correct about the desired behavior here. Will fix this.
@sloria This doesn't seem to be fixed. Was this change reverted? I tried to find any evidence of this in the master branch but I can't find the changes in this commit or any evidence of allow_blank as valid argument for validators.Email
I just found this PR: https://github.com/marshmallow-code/marshmallow/issues/167
But the change to remove allow_blank is missing from the changelog here: http://marshmallow.readthedocs.io/en/latest/changelog.html#changelog - would probably be helpful. (I was on 2.3 and used allow_blank extensively, this now just failed silently).
Most helpful comment
I just found this PR: https://github.com/marshmallow-code/marshmallow/issues/167
But the change to remove allow_blank is missing from the changelog here: http://marshmallow.readthedocs.io/en/latest/changelog.html#changelog - would probably be helpful. (I was on 2.3 and used allow_blank extensively, this now just failed silently).