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

In strict mode, raise UnmarshallingError with full errors dictionary #128

sloria opened this Issue Jan 18, 2015 · 0 comments


None yet
1 participant

sloria commented Jan 18, 2015

Currently, strict mode will cause an error to be raised as soon as validation fails on a field. The error contains information about the single field.

It would be more useful to validate the entire input dictionary and raise an error with the full errors dictionary.

from marshmallow import Schema, fields

class MySchema(Schema):
    email = fields.Email()
    homepage = fields.URL()

    class Meta:
        strict = True

s = MySchema()

# Current
s.validate({'email': 'invalid', 
            'homepage': 'not-a-url'})  # UnmarshallingError: ['"not-a-url" is not a valid URL.']

# Proposed
s.validate({'email': 'invalid', 
            'homepage': 'not-a-url'})  # UnmarshallingError: {'email': ['"invalid" is not a valid email.'],
                                       #                      'homepage': ['"not-a-url" is not a valid URL.']}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment