-
-
Notifications
You must be signed in to change notification settings - Fork 627
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
Dict data validated as fields.List: passes and silently drops data #189
Comments
I think this is related to #45 - will comment there. |
As per discussion in #45 I tried it with an explicit validate on dump. With a list of nested:from marshmallow import Schema, fields, pprint
class ListInnerSchema(Schema):
y = fields.Int()
class TestSchema(Schema):
x = fields.List(fields.Nested(ListInnerSchema), required=True)
schema = TestSchema()
begin = {'x': {'y1': 14}}
print('errors: {}'.format(schema.validate(begin)))
end = schema.dump(begin)
print('begin: {}'.format(begin))
print('end: {}'.format(end)) Output:
With nested many=True:from marshmallow import Schema, fields, pprint
class ListInnerSchema(Schema):
y = fields.Int()
class TestSchema(Schema):
x = fields.Nested(ListInnerSchema, many=True)
schema = TestSchema()
begin = {'x': {'y1': 14}}
print('errors: {}'.format(schema.validate(begin)))
end = schema.dump(begin)
print('begin: {}'.format(begin))
print('end: {}'.format(end)) Output:
I would expect an error to be returned from validate (and no exception thrown in any case). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the code I tested with:
Here's the output:
I didn't intend to dump a dict, but I had some bad data and it passed with no errors.
The text was updated successfully, but these errors were encountered: