marshmallow
marshmallow copied to clipboard
be more verbose: marshmallow.exceptions.ValidationError: {'_schema': ['Invalid input type.']}
im debugging an app that throws
marshmallow.exceptions.ValidationError: {'_schema': ['Invalid input type.']}
the problem is that marshmallow.Schema._deserialize
is called like
data = OrderedDict() # is_collection(data) == False
self._deserialize(data, many = True)
to fix this, i need either data = [ OrderedDict() ]
or many = False
it would be nice if the error message Invalid input type
would be more helpful here
for example
# marshmallow/schema.py
if many:
if not is_collection(data):
error_store.store_error([self.error_messages["type"]], index=index, detail="many but no collection")
ret_l = [] # type: typing.List[_T]
if not isinstance(data, Mapping):
error_store.store_error([self.error_messages["type"]], index=index, detail="data is no Mapping")
This would be incredibly helpful.
Would the project be open to a pull request that splits this into messages that include the expected type, but respects any custom error messages already defined?