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

Prefer `load_from` in nested errors about required fields #414

Closed
wants to merge 1 commit into
base: dev
from

Conversation

Projects
None yet
2 participants
@yumike
Contributor

yumike commented Mar 10, 2016

Given this schema

class UserSchema(Schema):
    time_registered = fields.DateTime(load_from='timeRegistered', required=True)

class BlogSchema(Schema):
    user = fields.Nested(UserSchema, required=True)

loading {} and {"user": {}} raises errors with different field names:

>>> schema = BlogSchema()

>>> schema.load({}).errors
{'user': {'time_registered': [u'Missing data for required field.']}}  # Invalid

>>> schema.load({"user": {}}).errors
{'user': {'timeRegistered': [u'Missing data for required field.']}}  # Valid
@sloria

This comment has been minimized.

Member

sloria commented Mar 11, 2016

Cherry-picked 528c36d into 2.6-line then forward-ported to dev. Thanks for the fix!

@sloria sloria closed this Mar 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment