Currently, ValidationError stores the field name and field instances associated with the error.
from marshmallow import Schema, fields
class MySchema(Schema):
foo = fields.Int()
schema = MySchema()
try:
schema.load({'foo': 'invalid'})
except Exception as error:
print(error.fields) # [<fields.Integer(...)>]
I propose removing the fields because it unnecessarily complicates the validation logic.
fields and field_names were added at a time (version 1.1.0 😓 ) when it was impossible to access all the error messages for a schema (see #63). It wasn't until 2.0 that it became possible to get the full error messages dict when using strict mode.
At this point, I don't see a use case for accessing ValidationError.fields.
Currently,
ValidationErrorstores the field name and field instances associated with the error.I propose removing the
fieldsbecause it unnecessarily complicates the validation logic.fieldsandfield_nameswere added at a time (version 1.1.0 😓 ) when it was impossible to access all the error messages for a schema (see #63). It wasn't until 2.0 that it became possible to get the full error messages dict when using strict mode.At this point, I don't see a use case for accessing
ValidationError.fields.