Bug fixes:
- Fix behavior of
fields.Contant(None)(:issue:`2868`). Thanks :user:`T90REAL` for reporting and emmanuel-ferdman for the fix.
Bug fixes:
- Fix validation of URLs beginning with uppercare FILE (:issue:`2891`). Thanks :user:`thanhlecongg` for reporting and fixing.
Other changes:
manyargument ofNestedproperly overrides schema instance value (:pr:`2854`). Thanks :user:`jafournier` for the PR.
Bug fixes:
- :cve:`2025-68480`: Merge error store messages without rebuilding collections. Thanks 카푸치노 for reporting and :user:`deckar01` for the fix.
Bug fixes:
- Ensure
URLvalidator is case-insensitive when using custom schemes (:pr:`2874`). Thanks :user:`T90REAL` for the PR.
Other changes:
- Add __len__ implementation to missing so that it can be used with validate.Length <marshmallow.validate.Length> (:pr:`2861`). Thanks :user:`agentgodzilla` for the PR.
- Drop support for Python 3.9 (:pr:`2363`).
- Test against Python 3.14 (:pr:`2864`).
Bug fixes:
- Fix wildcard import of
from marshmallow import *(:pr:`2823`). Thanks :user:`Florian-Laport` for the PR.
See :ref:`upgrading_4_0` for a guide on updating your code.
Features:
- Typing: Add types to all Field <marshmallow.fields.Field> constructor kwargs (:issue:`2285`). Thanks :user:`navignaw` for the suggestion.
- DateTime <marshmallow.fields.DateTime>, Date <marshmallow.fields.Date>, Time <marshmallow.fields.Time>, TimeDelta <marshmallow.fields.TimeDelta>, and Enum <marshmallow.fields.Enum> accept their internal value types as valid input (:issue:`1415`). Thanks :user:`bitdancer` for the suggestion.
- @validates <marshmallow.validates> accepts multiple field names (:issue:`1960`).
Backwards-incompatible: Decorated methods now receive
data_keyas a keyword argument. Thanks :user:`dpriskorn` for the suggestion and :user:`dharani7998` for the PR.
Other changes:
- Typing: Field <marshmallow.fields.Field> is now a generic type with a type argument for the internal value type.
- marshmallow.fields.UUID no longer subclasses marshmallow.fields.String.
- marshmallow.Schema.load no longer silently fails to call schema validators when a generator is passed (:issue:`1898`). The typing of data is also updated to be more accurate. Thanks :user:`ziplokk1` for reporting.
- Backwards-incompatible: Use datetime.date.fromisoformat, datetime.time.fromisoformat, and datetime.datetime.fromisoformat from the standard library to deserialize dates, times and datetimes (:pr:`2078`).
- As a consequence of this change:
- Time with time offsets are now supported.
- YYYY-MM-DD is now accepted as a datetime and deserialized as naive 00:00 AM.
- from_iso_date, from_iso_time and from_iso_datetime are removed from marshmallow.utils.
- Remove isoformat, to_iso_time and to_iso_datetime from marshmallow.utils (:pr:`2766`).
- Remove from_rfc, and rfcformat from marshmallow.utils (:pr:`2767`).
- Remove is_keyed_tuple from marshmallow.utils (:pr:`2768`).
- Remove get_fixed_timezone from marshmallow.utils (:pr:`2773`).
- Backwards-incompatible: marshmallow.fields.Boolean no longer serializes non-boolean values (:pr:`2725`).
- Backwards-incompatible: Rename
schemaparameter toparentin marshmallow.fields.Field._bind_to_schema (:issue:`1360`). - Backwards-incompatible: Rename
pass_manyparameter topass_collectionin pre/post processing methods (:issue:`1369`). - Backwards-incompatible: marshmallow.fields.TimeDelta no longer truncates float values when deserializing (:pr:`2654`). This allows microseconds to be preserved, e.g.
from marshmallow import fields
field = fields.TimeDelta()
# Before
field.deserialize(12.9)
datetime.timedelta(seconds=12)
# datetime.timedelta(seconds=12)
# After
field.deserialize(12.9)
# datetime.timedelta(seconds=12, microseconds=900000)- Improve performance and minimize float precision loss of marshmallow.fields.TimeDelta serialization (:pr:`2654`).
- Backwards-incompatible: Remove
serialization_typeparameter from marshmallow.fields.TimeDelta (:pr:`2654`).
Thanks :user:`ddelange` for the PR.
- Backwards-incompatible: Remove Schema <marshmallow.schema.Schema>'s
contextattribute (deprecated since 3.24.0). Passing a context should be done using contextvars.ContextVar (:issue:`1826`). marshmallow 4 provides an experimental Context <marshmallow.experimental.context.Context> manager class that can be used to both set and retrieve context.
import typing
from marshmallow import Schema, fields
from marshmallow.experimental.context import Context
class UserContext(typing.TypedDict):
suffix: str
class UserSchema(Schema):
name_suffixed = fields.Function(
lambda obj: obj["name"] + Context[UserContext].get()["suffix"]
)
with Context[UserContext]({"suffix": "bar"}):
UserSchema().dump({"name": "foo"})
# {'name_suffixed': 'foobar'}- Methods decorated with marshmallow.pre_load, marshmallow.post_load, marshmallow.validates_schema,
receive
unknownas a keyword argument (:pr:`1632`). Thanks :user:`jforand` for the PR. - Backwards-incompatible: Arguments to decorators <marshmallow.decorators> are keyword-only arguments.
- Backwards-incompatible: Rename
json_dataparameter of marshmallow.Schema.loads tosfor compatibility with most render module implementations (json,simplejson, etc.) (:pr:`2764`). Also make it a positional-only argument. - Incorrectly declaring a field using a field class rather than instance errors at class declaration time (previously happended when the schema was instantiated) (:pr:`2772`).
- Passing invalid values for
unknownwill cause an error in type checkers (:pr:`2771`).
Deprecations/Removals:
- Backwards-incompatible: Remove implicit field creation, i.e. using the
fieldsoradditionalclass Meta options with undeclared fields (:issue:`1356`). - The ordered class Meta option is removed (:issue:`2146`). Field order is already preserved by default. Set Schema.dict_class to OrderedDict to maintain the previous behavior.
- The marshmallow.base module is removed (:pr:`2722`).
Previously-deprecated APIs have been removed, including:
- The
orderedclass Meta <marshmallow.Schema.Meta> option is removed (:issue:`2146`) (deprecated in 3.26.0). - Backwards-incompatible: marshmallow.fields.Number is no longer usable as a field in a schema (deprecated in 3.24.0). Use marshmallow.fields.Integer, marshmallow.fields.Float, or marshmallow.fields.Decimal instead.
- Backwards-incompatible: marshmallow.fields.Mapping is no longer usable as a field in a schema (deprecated in 3.24.0).
- Backwards-incompatible: Custom validators must raise a ValidationError <marshmallow.exceptions.ValidationError> for invalid values (deprecated in 3.24.0). Returning False is no longer supported (:issue:`1775`). Use marshmallow.fields.Dict instead.
- Remove
__version__,__parsed_version__, and__version_info__attributes (deprecated in 3.21.0). - default and missing parameters, which were replaced by dump_default and load_default in 3.13.0 (:pr:`1742`, :pr:`2700`).
- Passing field metadata via keyword arguments (deprecated in 3.10.0). Use the explicit
metadata=...argument instead (:issue:`1350`). - marshmallow.utils.pprint (deprecated in 3.7.0). Use pprint.pprint instead.
- Passing "self" to fields.Nested (deprecated in 3.3.0). Use a callable instead.
Field.fail, which was replaced byField.make_errorin 3.0.0.- json_module class Meta option (deprecated in 3.0.0b3). Use render_module instead.
Bug fixes:
- :cve:`2025-68480`: Merge error store messages without rebuilding collections. Thanks 카푸치노 for reporting and :user:`deckar01` for the fix.
Bug fixes:
- Typing: Fix type annotations for class Meta <marshmallow.Schema.Meta> options (:issue:`2804`). Thanks :user:`lawrence-law` for reporting.
Other changes:
- Remove default value for the
dataparam of Nested._deserialize <marshmallow.fields.Nested._deserialize> (:issue:`2802`). Thanks :user:`gbenson` for reporting.
Features:
- Typing: Add type annotations and improved documentation for class Meta <marshmallow.Schema.Meta> options (:pr:`2760`).
- Typing: Improve type coverage of marshmallow.Schema.SchemaMeta (:pr:`2761`).
- Typing: marshmallow.Schema.loads parameter allows bytes and bytesarray (:pr:`2769`).
Bug fixes:
- Respect
data_keywhen schema validators raise a ValidationError <marshmallow.exceptions.ValidationError> with afield_nameargument (:issue:`2170`). Thanks :user:`matejsp` for reporting. - Correctly handle multiple @post_load <marshmallow.post_load> methods where one method appends to
the data and another passes
pass_original=True(:issue:`1755`). Thanks :user:`ghostwheel42` for reporting. URLfields now properly validatefilepaths (:issue:`2249`). Thanks :user:`0xDEC0DE` for reporting and fixing.
Documentation:
- Add :doc:`upgrading guides <upgrading>` for 3.24 and 3.26 (:pr:`2780`).
- Various documentation improvements (:pr:`2757`, :pr:`2759`, :pr:`2765`, :pr:`2774`, :pr:`2778`, :pr:`2783`, :pr:`2796`).
Deprecations:
- The
orderedclass Meta <marshmallow.Schema.Meta> option is deprecated (:issue:`2146`, :pr:`2762`). Field order is already preserved by default. Set marshmallow.Schema.dict_class to collections.OrderedDict to maintain the previous behavior.
Bug fixes:
- Typing: Fix type annotations for Tuple <marshmallow.fields.Tuple>, Boolean <marshmallow.fields.Boolean>, and Pluck <marshmallow.fields.Pluck> constructors (:pr:`2756`).
- Typing: Fix overload for marshmallow.class_registry.get_class (:pr:`2756`).
Documentation:
- Various documentation improvements (:pr:`2746`, :pr:`2747`, :pr:`2748`, :pr:`2749`, :pr:`2750`, :pr:`2751`).
Features:
- Typing: Improve type annotations for
SchemaMeta.get_declared_fields(:pr:`2742`).
Bug fixes:
- Typing: Relax type annotation for
Schema.optsto allow subclasses to define their own options classes (:pr:`2744`).
Other changes:
- Restore
marshmallow.base.SchemaABCfor backwards-compatibility (:issue:`2743`). Note that this class is deprecated and will be removed in marshmallow 4. Use marshmallow.schema.Schema as a base class for type-checking instead.
Changes:
- Don't override
__new__to avoid breaking usages of inspect.signature with Field <marshmallow.fields.Field> classes. This allows marshmallow-sqlalchemy users to upgrade marshmallow without upgrading to marshmallow-sqlalchemy>=1.1.1.
Documentation:
- Add top-level API back to docs (:issue:`2739`). Thanks :user:`llucax` for reporting.
Bug fixes:
- Typing: Fix typing for class_registry.get_class <marshmallow.class_registry.get_class> (:pr:`2735`).
Features:
- Typing: Improve typings in marshmallow.fields (:pr:`2723`).
- Typing: Replace type comments with inline typings (:pr:`2718`).
Bug fixes:
- Typing: Fix type hint for
nestedparameter of Nested <marshmallow.fields.Nested> (:pr:`2721`).
Deprecations:
- Custom validators should raise a ValidationError <marshmallow.exceptions.ValidationError> for invalid values. Returning False` is no longer supported .
- Deprecate
contextparameter of Schema <marshmallow.schema.Schema> (:issue:`1826`). Use contextVars.ContextVar to pass context data instead. - Field <marshmallow.fields.Field>, Mapping <marshmallow.fields.Mapping>, and Number <marshmallow.fields.Number> should no longer be used as fields within schemas. Use their subclasses instead.
Bug fixes:
- Typing: Fix typing for Schema.from_dict <marshmallow.schema.Schema.from_dict> (:issue:`1653`). Thanks :user:`SteadBytes` for reporting.
Support:
- Documentation: Various documentation cleanups, including more concise docs in the marshmallow.fields API reference (:issue:`2307`). Thanks :user:`AbdealiLoKo` for reporting.
Bug fixes:
- Improve type hint formatting for
Field,Nested, andFunctionfields to resolve PyCharm warnings (:issue:`2268`). Thanks :user:`Fares-Abubaker` for reporting and fixing.
Support:
- Document
absoluteparameter ofURLfield (:pr:`2327`). - Documentation: Remove (outdated) minimum Python 3 minor version in documentation and README (:pr:`2323`).
Features:
- Typing: replace "type" with specific metaclass for
SchemaandField.
Other changes:
- Officially support Python 3.13 (:pr:`2319`).
- Drop support for Python 3.8 (:pr:`2318`).
Features:
- Add
manyMeta option toSchemaso it expects a collection by default (:issue:`2270`). Thanks :user:`himalczyk` for reporting and :user:`deckar01` for the PR. - Refactor hooks (:pr:`2279`). Thanks :user:`deckar01` for the PR.
Bug fixes:
- Fix memory leak that prevented schema instances from getting GC'd (:pr:`2277`). Thanks :user:`mrcljx` for the PR.
Bug fixes:
- Allow timestamp 0 in
fields.DateTime(:issue:`2133`). Thanks :user:`flydzen` for reporting.
Bug fixes:
- Fix error message when field is declared as a class and not an instance (:issue:`2245`). Thanks :user:`travnick` for reporting.
Bug fixes:
- Fix validation of
URLfields to allow missing user field, per NWG RFC 3986 (:issue:`2232`). Thanks :user:`ddennerline3` for reporting and :user:`deckar01` for the PR.
Other changes:
- Backwards-incompatible:
__version__,__parsed_version__, and__version_info__attributes are deprecated (:issue:`2227`). Use feature detection orimportlib.metadata.version("marshmallow")instead.
Bug fixes:
- Fix
Nestedfield type hint for lambdaSchematypes (:pr:`2164`). Thanks :user:`somethingnew2-0` for the PR.
Other changes:
- Officially support Python 3.12 (:pr:`2188`). Thanks :user:`hugovk` for the PR.
Bug fixes:
- Fix call to
get_declared_fields: passdict_clsagain (:issue:`2152`). Thanks :user:`Cheaterman` for reporting.
Features:
- Add
absoluteparameter toURLvalidator andUrlfield (:pr:`2123`). Thanks :user:`sirosen` for the PR. - Use Abstract Base Classes to define
FieldABCandSchemaABC(:issue:`1449`). Thanks :user:`aditkumar72` for the PR. - Use OrderedSet as default set_class. Schemas are now ordered by default. (:issue:`1744`)
Bug fixes:
- Handle
OSErrorandOverflowErrorinutils.from_timestamp(:pr:`2102`). Thanks :user:`TheBigRoomXXL` for the PR. - Fix the default inheritance of nested partial schemas (:issue:`2149`). Thanks :user:`matejsp` for reporting.
Other changes:
- Officially support Python 3.11 (:pr:`2067`).
- Drop support for Python 3.7 (:pr:`2135`).
Features:
- Add
timestampandtimestamp_msformats tofields.DateTime(:issue:`612`). Thanks :user:`vgavro` for the suggestion and thanks :user:`vanHoi` for the PR.
Features:
- Add
Enumfield (:pr:`2017`) and (:pr:`2044`).
Bug fixes:
- Fix typing in
Field._serializesignature (:pr:`2046`).
Bug fixes:
- Add return type to
fields.Email.__init__(:pr:`2018`). Thanks :user:`kkirsche` for the PR. - Add missing type hint to IPInterface __init__ (:pr:`2036`).
Features:
- Support serialization as float in
TimeDeltafield (:pr:`1998`). Thanks :user:`marcosatti` for the PR. - Add
messages_dictproperty toValidationErrorto facilitate type checking (:pr:`1976`). Thanks :user:`sirosen` for the PR.
Features:
- Raise
ValueErrorif an invalid value is passed to theunknownargument (:issue:`1721`, :issue:`1732`). Thanks :user:`sirosen` for the PR.
Other changes:
- Set lower bound for
packagingrequirement (:issue:`1957`). Thanks :user:`MatthewNicolTR` for reporting and thanks :user:`sirosen` for the PR. - Improve warning messages by passing
stacklevel(:pr:`1986`). Thanks :user:`tirkarthi` for the PR.
Features:
- Allow passing a
dicttofields.Nested(:pr:`1935`). Thanks :user:`sirosen` for the PR.
Other changes:
- Address distutils deprecation warning in Python 3.10 (:pr:`1903`). Thanks :user:`kkirsche` for the PR.
- Add py310 to black target-version (:pr:`1921`).
- Drop support for Python 3.6 (:pr:`1923`).
- Use postponed evaluation of annotations (:pr:`1932`). Thanks :user:`Isira-Seneviratne` for the PR.
Bug fixes:
- Fix publishing type hints per PEP-561 (:pr:`1905`). Thanks :user:`bwindsor` for the catch and patch.
Bug fixes:
- Fix
fields.TimeDeltaserialization precision (:issue:`1865`). Thanks :user:`yarsanich` for reporting.
Other changes:
- Fix type-hints for
dataarg inSchema.validateto accept list of dictionaries (:issue:`1790`, :pr:`1868`). Thanks :user:`yourun-proger` for PR. - Improve warning when passing metadata as keyword arguments (:pr:`1882`). Thanks :user:`traherom` for the PR.
- Don't build universal wheels. We don't support Python 2 anymore. (:issue:`1860`) Thanks :user:`YKdvd` for reporting.
- Make the build reproducible (:pr:`1862`).
- Drop support for Python 3.5 (:pr:`1863`).
- Test against Python 3.10 (:pr:`1888`).
Features:
- Replace
missing/defaultfield parameters withload_default/dump_default(:pr:`1742`). Thanks :user:`sirosen` for the PR.
Deprecations:
- The use of
missing/defaultfield parameters is deprecated and will be removed in marshmallow 4.load_default/dump_defaultshould be used instead.
Bug fixes:
- Don't expose
Fields asSchemaattributes. This reverts a change introduced in 3.12.0 that causes issues when field names conflict withSchemaattributes or methods.Fieldss are still accessible on aSchemainstance through thefieldsattribute. (:pr:`1843`)
Bug fixes:
- Fix bug that raised an
AttributeErrorwhen instantiating aSchemawith a field namedparent(:issue:`1808`). Thanks :user:`flying-sheep` for reporting and helping with the fix.
Features:
- Add
validate.And(:issue:`1768`). Thanks :user:`rugleb` for the suggestion. - Add type annotations to
marshmallow.decorators(:issue:`1788`, :pr:`1789`). Thanks :user:`michaeldimchuk` for the PR. - Let
Fields be accessed by name asSchemaattributes (:pr:`1631`).
Other changes:
- Improve types in
marshmallow.validate(:pr:`1786`). - Make
marshmallow.validate.Validatoran abstract base class (:pr:`1786`). - Remove unnecessary list cast (:pr:`1785`).
Bug fixes:
- Fix treatment of dotted keys when
unknown=INCLUDE(:issue:`1506`). Thanks :user:`rbu` for reporting and thanks :user:`sirosen` for the fix (:pr:`1745`).
Features:
- Add
fields.IPInterface,fields.IPv4Interface, andIPv6Interface(:issue:`1733`). Thanks :user:`madeinoz67` for the suggestion and the PR. - Raise
AttributeErrorfor missing methods when usingfields.Method(:pr:`1675`). Thanks :user:`lassandroan`.
Other changes:
- Remove unnecessary
hasattrandgetattrchecks inField(:pr:`1770`).
Deprecations:
- Passing field metadata via keyword arguments is deprecated and will be
removed in marshmallow 4 (:issue:`1350`). Use the explicit
metadata=...argument instead. Thanks :user:`sirosen`.
Bug fixes:
- Cast to mapping type in
Mapping.serializeandMapping.deserialize(:pr:`1685`). - Fix bug letting
Dictpass invalid dict on deserialization when no key or valueFieldis specified (:pr:`1685`).
Features:
- Add
formatargument tofields.Timeandtimeformatclass Metaoption (:issue:`686`). Thanks :user:`BennyAlex` for the suggestion and thanks :user:`infinityxxx` for the PR.
Other changes:
- Remove usage of implicit
typing.Optional(:issue:`1663`). Thanks :user:`nadega` for the PR.
Features:
- Add
fields.IP,fields.IPv4andfields.IPv6(:pr:`1485`). Thanks :user:`mgetka` for the PR.
Bug fixes:
- Fix typing in
AwareDateTime(:pr:`1658`). Thanks :user:`adithyabsk` for reporting.
Bug fixes:
fields.Booleancorrectly serializes non-hashable types (:pr:`1633`). Thanks :user:`jun0jang` for the PR.
Deprecations:
marshmallow.pprintis deprecated and will be removed in marshmallow 4 (:issue:`1588`).
Support:
- Document
default_error_messageson field classes (:pr:`1619`). Thanks :user:`weeix`.
Bug fixes:
- Fix passing
onlyandexcludetoNestedwith an orderedSchema(:pr:`1627`). Thanks :user:`juannorris` for the PR.
No code changes--only docs and contributor-facing updates in this release.
Support:
- Documentation: improve custom fields example (:issue:`1538`). Thanks :user:`pablospizzamiglio` for reporting the problem with the old example and thanks :user:`Resinderate` for the PR.
- Documentation: Split up API reference into multiple pages and add summary tables (:pr:`1587`). Thanks :user:`EpicWink` for the PR.
Features:
- Add
validate.ContainsNoneOf(:issue:`1528`). Thanks :user:`Resinderate` for the suggestion and the PR.
Bug fixes:
- Fix typing in
class_registry(:pr:`1574`). Thanks :user:`mahenzon`.
Bug fixes:
- Includes bug fix from 2.21.0.
Bug fixes:
- Fix list of nullable nested fields
List(Nested(Field, allow_none=True)(:issue:`1497`). Because this fix reverts an optimization introduced to speed-up serialization and deserialization of lists of nested fields, a negative impact on performance in this specific case is expected.
Features:
- Improve type coverage (:issue:`1479`). Thanks :user:`Reskov`.
Bug fixes:
- Fix typing for
dataparam ofSchema.loadandValidationError(:issue:`1492`). Thanks :user:`mehdigmira` for reporting and thanks :user:`dfirst` for the PR.
Other changes:
- Remove unnecessary typecasts (:pr:`1500`). Thanks :user:`hukkinj1`.
- Remove useless
_serializeoverride inUUIDfield (:pr:`1489`).
Features:
fields.Nestedmay take a callable that returns a schema instance. Use this to resolve order-of-declaration issues when schemas nest each other (:issue:`1146`).
# <3.3
class AlbumSchema(Schema):
title = fields.Str()
artist = fields.Nested("ArtistSchema", only=("name",))
class ArtistSchema(Schema):
name = fields.Str()
albums = fields.List(fields.Nested(AlbumSchema))
# >=3.3
class AlbumSchema(Schema):
title = fields.Str()
artist = fields.Nested(lambda: ArtistSchema(only=("name",)))
class ArtistSchema(Schema):
name = fields.Str()
albums = fields.List(fields.Nested(AlbumSchema))Deprecations:
- Passing the string
"self"tofields.Nestedis deprecated. Use a callable instead.
from marshmallow import Schema, fields
# <3.3
class PersonSchema(Schema):
partner = fields.Nested("self", exclude=("partner",))
friends = fields.List(fields.Nested("self"))
# >=3.3
class PersonSchema(Schema):
partner = fields.Nested(lambda: PersonSchema(exclude=("partner")))
friends = fields.List(fields.Nested(lambda: PersonSchema()))Other changes:
- Fix typing for
Number._format_num(:pr:`1466`). Thanks :user:`hukkinj1`. - Make mypy stricter and remove dead code (:pr:`1467`). Thanks again, :user:`hukkinj1`.
Bug fixes:
- Don't load fields for which
load_onlyanddump_onlyare bothTrue(:pr:`1448`). - Fix types in
marshmallow.validate(:pr:`1446`).
Support:
- Test against Python 3.8 (:pr:`1431`).
Bug fixes:
- Fix typing for
Schema.dump[s](:pr:`1416`).
Features:
- Add type annotations to
marshmallow.schemaandmarshmallow.validate(:pr:`1407`, :issue:`663`).
Bug fixes:
- Fix compatibility with Python < 3.5.3 (:issue:`1409`). Thanks :user:`lukaszdudek-silvair` for reporting.
Refactoring:
- Remove unnecessary
BaseSchemasuperclass (:pr:`1406`).
Bug fixes:
- Restore inheritance hierarchy of
Numberfields (:pr:`1403`).fields.Integerandfields.Decimalinherit fromfields.Number. - Fix bug that raised an uncaught error when a nested schema instance had an unpickleable object in its context (:issue:`1404`). Thanks :user:`metheoryt` for reporting.
Features:
- Add more type annotations (:issue:`663`). Type information is distributed per PEP 561 . Thanks :user:`fuhrysteve` for helping with this.
Bug fixes:
- Includes bug fix from 2.20.5.
Bug fixes:
- Fix bug that raised an uncaught error when passing both a schema instance and
onlytoNested(:pr:`1395`). This bug also affected passing a schema instance tofields.Pluck.
Bug fixes:
- Fix propagating dot-delimited
onlyandexcludeparameters to nested schema instances (:issue:`1384`). - Includes bug fix from 2.20.4 (:issue:`1160`).
Bug fixes:
- Handle when
data_keyis an empty string (:issue:`1378`). Thanks :user:`jtrakk` for reporting.
Bug fixes:
- Includes bug fix from 2.20.3 (:pr:`1376`).
- Fix incorrect
super()call inSchemaMeta.__init__(:pr:`1362`).
Bug fixes:
- Fix bug when nesting
fields.DateTimewithinfields.Listorfields.Tuple(:issue:`1357`). This bug was introduced in 3.0.0rc9. Thanks :user:`zblz` for reporting.
Features:
- Optimize
List(Nested(...))(:issue:`779`). - Minor performance improvements and cleanup (:pr:`1328`).
- Add
Schema.from_dict(:issue:`1312`).
Deprecations/Removals:
Field.failis deprecated. UseField.make_errorinstead.- Remove UUID validation from
fields.UUID, for consistency with other fields (:issue:`1132`).
Support:
- Various docs improvements (:pr:`1329`).
Features:
- Backwards-incompatible: Validation does not occur on serialization (:issue:`1132`). This significantly improves serialization performance.
- Backwards-incompatible:
DateTimedoes not affect timezone information on serialization and deserialization (:issue:`1234`, :pr:`1278`). - Add
NaiveDateTimeandAwareDateTimeto enforce timezone awareness (:issue:`1234`, :pr:`1287`). - Backwards-incompatible:
Listdoes not wrap single values in a list on serialization (:pr:`1307`). - Backwards-incompatible:
Schema.handle_errorreceivesmanyandpartialas keyword arguments (:pr:`1321`). - Use
raise frommore uniformly to improve stack traces (:pr:`1313`). - Rename
Nested.__schematoNested._schemato prevent name mangling (:issue:`1289`). - Performance improvements (:pr:`1309`).
Deprecations/Removals:
LocalDateTimeis removed (:issue:`1234`).marshmallow.utils.utcis removed. Usedatetime.timezone.utcinstead.
Bug fixes:
- Fix behavior of
List(Nested("self"))(#779 (comment)).
Support:
- Document usage of
validate.Regexp's usagere.search(:issue:`1285`). Thanks :user:`macdonaldezra`.
Features:
- Propagate
onlyandexcludeparameters toNestedfields withinListandDict(:issue:`779`, :issue:`946`). - Use
email.utils.parsedate_to_datetimeinstead of conditionally using dateutil for parsing RFC dates (:pr:`1246`). - Use internal util functions instead of conditionally using dateutil for parsing ISO 8601 datetimes, dates and times. Timezone info is now correctly deserialized whether or not dateutil is installed. (:pr:`1265`)
- Improve error messages for
validate.Range. - Use
raise from errorfor better stack traces (:pr:`1254`). Thanks :user:`fuhrysteve`. - python-dateutil is no longer used. This resolves the inconsistent behavior based on the presence of python-dateutil (:issue:`497`, :issue:`1234`).
Bug fixes:
- Fix method resolution for
__init__method offields.Emailandfields.URL(:issue:`1268`). Thanks :user:`dursk` for the catch and patch. - Includes bug fixes from 2.19.4 and 2.19.5.
Other changes:
- Backwards-incompatible: Rename
fields.List.containertofields.List.inner,fields.Dict.key_containertofields.Dict.key_field, andfields.Dict.value_containertofields.Dict.value_field. - Switch to Azure Pipelines for CI (:issue:`1261`).
Features:
- Backwards-incompatible:
manyis passed as a keyword argument to methods decorated withpre_load,post_load,pre_dump,post_dump, andvalidates_schema.partialis passed as a keyword argument to methods decorated withpre_load,post_loadandvalidates_schema.**kwargsshould be added to all decorated methods. - Add
min_inclusiveandmax_exclusiveparameters tovalidate.Range(:issue:`1221`). Thanks :user:`kdop` for the PR.
Bug fixes:
- Fix propagation of
partialtoNestedcontainers (part of :issue:`779`). - Includes bug fix from 2.19.3.
Other changes:
- Backwards-incompatible: Use keyword-only arguments (:issue:`1216`).
Support:
- Backwards-incompatible: Remove support for Python 2 (:issue:`1120`). Only Python>=3.5 is supported. Thank you :user:`rooterkyberian` for the suggestion and the PR.
- Backwards-incompatible: Remove special-casing in
fields.Listandfields.Tuplefor accessing nested attributes (:pr:`1188`). Usefields.List(fields.Pluck(...))instead. - Add
python_requirestosetup.py(:pr:`1194`). Thanks :user:`hugovk`. - Upgrade syntax with
pyupgradein pre-commit (:pr:`1195`). Thanks again :user:`hugovk`.
Features:
- Allow input value to be included in error messages for a number of fields (:pr:`1129`). Thanks :user:`hdoupe` for the PR.
- Improve default error messages for
OneOfandContainsOnly(:issue:`885`). Thanks :user:`mcgfeller` for the suggestion and :user:`maxalbert` for the PR.
Deprecations/Removals:
- Remove
fields.FormattedString(:issue:`1141`). Usefields.Functionorfields.Methodinstead.
Bug fixes:
- Includes bug fix from 2.19.2.
Features:
- Add
fields.Tuple(:issue:`1103`) Thanks :user:`zblz` for the PR. - Add
fields.Mapping, which makes it easier to support other mapping types (e.g.OrderedDict) (:issue:`1092`). Thank :user:`sayanarijit` for the suggestion and the PR.
Features:
- Make the error messages for "unknown fields" and "invalid data type" configurable (:issue:`852`). Thanks :user:`Dunstrom` for the PR.
fields.Booleanparses"yes"/"no"values (:pr:`1081`). Thanks :user:`r1b`.
Other changes:
- Backwards-incompatible with previous 3.x versions: Change ordering
of
keysandvaluesarguments tofields.Dict. - Remove unused code in
marshmallow.utils:is_indexable_but_not_string,float_to_decimal,decimal_to_fixed,from_iso(:pr:`1088`). - Remove unused
marshmallow.compat.string_types.
Bug fixes:
- Includes bug fix from 2.18.0.
Features:
- Add
registerclass Meta option to allow bypassing marshmallow's internal class registry when memory usage is critical (:issue:`660`).
Bug fixes:
- Fix serializing dict-like objects with properties (:issue:`1060`). Thanks :user:`taion` for the fix.
- Fix populating
ValidationError.valid_dataforListandDictfields (:issue:`766`).
Other changes:
- Add
marshmallow.__version_info__(:pr:`1074`). - Remove the
marshmallow.marshallinginternal module (:pr:`1070`). - A
ValueErroris raised when themissingparameter is passed for required fields (:issue:`1040`). - Extra keyword arguments passed to
ValidationErrorin validators are no longer passed to the finalValidationErrorraised upon validation completion (:issue:`996`).
Features:
- Backwards-incompatible: Rework
ValidationErrorAPI. It now expects a single field name, and error structures are merged in the finalValidationErrorraised when validation completes. This allows schema-level validators to raise errors for individual fields (:issue:`441`). Thanks :user:`maximkulkin` for writing the originalmerge_errorsimplementation in :pr:`442` and thanks :user:`lafrech` for completing the implementation in :pr:`1026`.
Bug fixes:
- Fix
TypeErrorwhen serializingNonewithPluck(:pr:`1049`). Thanks :user:`toffan` for the catch and patch.
Bug fixes:
- Includes bug fixes from 2.16.2 and 2.16.3.
Features:
- Support partial loading of nested fields (:pr:`438`). Thanks
:user:`arbor-dwatson` for the PR. Note: Subclasses of
fields.Nestednow take an additionalpartialparameter in the_deserializemethod.
Bug fixes:
- Restore
Schema.TYPE_MAPPING, which was removed in 3.0.0b17 (:issue:`1012`).
Other changes:
- Backwards-incompatible:
_serializeand_deserializemethods of allfields.Fieldsubclasses must accept**kwargs(:pr:`1007`).
Bug fixes:
- Fix
Datedeserialization when using custom format (:issue:`1001`). Thanks :user:`Ondkloss` for reporting.
Deprecations/Removals:
prefixparameter orSchemaclass is removed (:issue:`991`). The same can be achieved using a@post_dumpmethod.
Features:
- Add
formatoption toDatefield (:pr:`869`). - Backwards-incompatible: Rename
DateTime'sdateformatMeta option todatetimeformat.dateformatnow applies toDate(:pr:`869`). Thanks :user:`knagra` for implementing these changes. - Enforce ISO 8601 when deserializing date and time (:issue:`899`). Thanks :user:`dushr` for the report and the work on the PR.
- Backwards-incompatible: Raise
ValueErroronSchemainstantiation in case ofattributeordata_keycollision (:pr:`992`).
Bug fixes:
- Fix inconsistencies in field inference by refactoring the inference feature into a dedicated field (:issue:`809`). Thanks :user:`taion` for the PR.
- When
unknownis not passed toNested, default to nestedSchemaunknownmeta option rather thanRAISE(:pr:`963`). Thanks :user:`vgavro` for the PR. - Fix loading behavior of
fields.Pluck(:pr:`990`). - Includes bug fix from 2.16.0.
Bug fixes:
- Fix
rootattribute for nested container fields on inheriting schemas (:issue:`956`). Thanks :user:`bmcbu` for reporting.
Bug fixes:
- Raise
ValidationErrorinstead ofTypeErrorwhen non-iterable types are validated withmany=True(:issue:`851`). many=Trueno longer iterates overstrandcollections.abc.Mappingobjects and instead raises aValidationErrorwith{'_schema': ['Invalid input type.']}(:issue:`930`).- Return
[]asValidationError.valid_datainstead of{}whenmany=True(:issue:`907`).
Thanks :user:`tuukkamustonen` for implementing these changes.
Features:
- Add
fields.Pluckfor serializing a single field from a nested object (:issue:`800`). Thanks :user:`timc13` for the feedback and :user:`deckar01` for the implementation. - Backwards-incompatible: Passing a string argument as
onlytofields.Nestedis no longer supported. Usefields.Pluckinstead (:issue:`800`). - Raise a
StringNotCollectionErrorifonlyorexcludeis passed as a string tofields.Nested(:pr:`931`). - Backwards-incompatible:
Floattakes anallow_nanparameter to explicitly allow serializing and deserializing special values (nan,infand-inf).allow_nandefaults toFalse.
Other changes:
- Backwards-incompatible:
Nestedfield now defaults tounknown=RAISEinstead ofEXCLUDE. This harmonizes behavior withSchemathat already defaults toRAISE(:issue:`908`). Thanks :user:`tuukkamustonen`. - Tested against Python 3.7.
Bug fixes:
- Errors reported by a schema-level validator for a field in a
Nestedfield are stored under corresponding field name, not_schemakey (:pr:`862`). - Includes bug fix from 2.15.4.
Other changes:
- Backwards-incompatible: The
unknownoption now defaults toRAISE(#524 (comment), :issue:`851`). - Backwards-incompatible: When a schema error is raised with a
dictas payload, thedictoverwrites any existing error list. Before this change, it would be appended to the list. - Raise a StringNotCollectionError if
onlyorexcludeis passed as a string (:issue:`316`). Thanks :user:`paulocheque` for reporting.
Features:
- The behavior to apply when encountering unknown fields while deserializing
can be controlled with the
unknownoption (:issue:`524`, :issue:`747`, :issue:`127`). It makes it possible to either "include", "exclude", or "raise". Thanks :user:`tuukkamustonen` for the suggestion and thanks :user:`ramnes` for the PR.
Warning
The default for unknown will be changed to RAISE in the
next release.
Other changes:
- Backwards-incompatible: Pre/Post-processors MUST return modified data.
Returning
Nonedoes not imply data were mutated (:issue:`347`). Thanks :user:`tdevelioglu` for reporting. - Backwards-incompatible:
onlyandexcludeare bound by declared and additional fields. AValueErroris raised if invalid fields are passed (:issue:`636`). Thanks :user:`jan-23` for reporting. Thanks :user:`ikilledthecat` and :user:`deckar01` for the PRs. - Format code using pre-commit (:pr:`855`).
Deprecations/Removals:
ValidationError.fieldsis removed (:issue:`840`). Access field instances fromSchema.fields.
Features:
- Clean up code for schema hooks (:pr:`814`). Thanks :user:`taion`.
- Minor performance improvement from simplifying
utils.get_value(:pr:`811`). Thanks again :user:`taion`. - Add
require_tldargument tofields.URL(:issue:`749`). Thanks :user:`DenerKup` for reporting and thanks :user:`surik00` for the PR. fields.UUIDdeserializesbytesstrings usingUUID(bytes=b'...')(:pr:`625`). Thanks :user:`JeffBerger` for the suggestion and the PR.
Bug fixes:
- Fields nested within
Dictcorrectly inherit context from their parent schema (:issue:`820`). Thanks :user:`RosanneZe` for reporting and :user:`deckar01` for the PR. - Includes bug fix from 2.15.3.
Bug fixes:
- Includes bugfixes from 2.15.2.
Features:
- Backwards-incompatible:
missinganddefaultvalues are passed in deserialized form (:issue:`378`). Thanks :user:`chadrik` for the suggestion and thanks :user:`lafrech` for the PR.
Bug fixes:
- Includes the bugfix from 2.15.1.
Features:
- Backwards-incompatible: Add
data_keyparameter to fields for specifying the key in the input and output data dict. This parameter replaces bothload_fromanddump_to(:issue:`717`). Thanks :user:`lafrech`. - Backwards-incompatible: When
pass_original=Trueis passed to one of the decorators and a collection is being (de)serialized, theoriginal_dataargument will be a single object unlesspass_many=Trueis also passed to the decorator (:issue:`315`, :issue:`743`). Thanks :user:`stj` for the PR. - Backwards-incompatible: Don't recursively check nested required
fields when the
Nestedfield's key is missing (:issue:`319`). This reverts :pr:`235`. Thanks :user:`chekunkov` reporting and thanks :user:`lafrech` for the PR. - Backwards-incompatible: Change error message collection for
Dictfield (:issue:`730`). Note: this is backwards-incompatible with previous 3.0.0bX versions. Thanks :user:`shabble` for the report and thanks :user:`lafrech` for the PR.
Features:
- Backwards-incompatible: Schemas are always strict (:issue:`377`).
The
strictparameter is removed. - Backwards-incompatible:
Schema().loadandSchema().dumpreturndatainstead of a(data, errors)tuple (:issue:`598`). - Backwards-incompatible:
Schema().load(None)raises aValidationError(:issue:`511`).
See :ref:`upgrading_3_0` for a guide on updating your code.
Thanks :user:`lafrech` for implementing these changes. Special thanks to :user:`MichalKononenko`, :user:`douglas-treadwell`, and :user:`maximkulkin` for the discussions on these changes.
Other changes:
- Backwards-incompatible: Field name is not checked when
load_fromis specified (:pr:`714`). Thanks :user:`lafrech`.
Support:
- Add Code of Conduct.
Bug fixes:
- Fixes
ValidationError.valid_datawhen a nested field contains errors (:issue:`710`). This bug was introduced in 3.0.0b3. Thanks :user:`lafrech`.
Other changes:
- Backwards-incompatible:
EmailandURLfields don't validate on serialization (:issue:`608`). This makes them more consistent with the other fields and improves serialization performance. Thanks again :user:`lafrech`. validate.URLrequires square brackets around IPv6 URLs (:issue:`707`). Thanks :user:`harlov`.
Features:
- Add support for structured dictionaries by providing values and keys arguments to the
Dictfield's constructor. This mirrors theListfield's ability to validate its items (:issue:`483`). Thanks :user:`deckar01`.
Other changes:
- Backwards-incompatible:
utils.from_isois deprecated in favor ofutils.from_iso_datetime(:issue:`694`). Thanks :user:`sklarsa`.
Features:
- Add support for millisecond, minute, hour, and week precisions to
fields.TimeDelta(:issue:`537`). Thanks :user:`Fedalto` for the suggestion and the PR. - Includes features from release 2.14.0.
Support:
- Copyright year in docs uses
CHANGELOG.rst's modified date for reproducible builds (:issue:`679`). Thanks :user:`bmwiedemann`. - Test against Python 3.6 in tox. Thanks :user:`Fedalto`.
- Fix typo in exception message (:issue:`659`). Thanks :user:`wonderbeyond` for reporting and thanks :user:`yoichi` for the PR.
Features:
- Add
valid_dataattribute toValidationError. - Add
strictparameter toInteger(:issue:`667`). Thanks :user:`yoichi`.
Deprecations/Removals:
- Deprecate
json_moduleoption in favor ofrender_module(:issue:`364`, :issue:`130`). Thanks :user:`justanr` for the suggestion.
Bug fixes:
- Includes bug fixes from releases 2.13.5 and 2.13.6.
- Backwards-incompatible:
Numberfields don't accept booleans as valid input (:issue:`623`). Thanks :user:`tuukkamustonen` for the suggestion and thanks :user:`rowillia` for the PR.
Support:
- Add benchmark script. Thanks :user:`rowillia`.
Features:
- Add
truthyandfalsyparams tofields.Boolean(:issue:`580`). Thanks :user:`zwack` for the PR. Note: This is potentially a breaking change if your code passes the default parameter positionally. Pass default as a keyword argument instead, e.g.fields.Boolean(default=True).
Other changes:
- Backwards-incompatible:
validate.ContainsOnlyallows empty and duplicate values (:issue:`516`, :issue:`603`). Thanks :user:`maximkulkin` for the suggestion and thanks :user:`lafrech` for the PR.
Bug fixes:
- Includes bug fixes from release 2.13.4.
Features:
fields.Nestedrespectsonly='field'when deserializing (:issue:`307`). Thanks :user:`erlingbo` for the suggestion and the PR.fields.Booleanparses"on"/"off"(:issue:`580`). Thanks :user:`marcellarius` for the suggestion.
Other changes:
- Includes changes from release 2.13.2.
- Backwards-incompatible:
skip_on_field_errorsdefaults toTrueforvalidates_schema(:issue:`352`).
Features:
dump_onlyandload_onlyforFunctionandMethodare set based onserializeanddeserializearguments (:issue:`328`).
Other changes:
- Backwards-incompatible:
fields.Methodandfields.Functionno longer swallowAttributeErrors(:issue:`395`). Thanks :user:`bereal` for the suggestion. - Backwards-incompatible:
validators.Lengthis no longer a subclass ofvalidators.Range(:issue:`458`). Thanks :user:`deckar01` for the catch and patch. - Backwards-incompatible:
utils.get_func_argsno longer returns bound arguments. This is consistent with the behavior ofinspect.signature. This change prevents a DeprecationWarning on Python 3.5 (:issue:`415`, :issue:`479`). Thanks :user:`deckar01` for the PR. - Backwards-incompatible: Change the signature of
utils.get_valueandSchema.get_attributefor consistency with Python builtins (e.g.getattr) (:issue:`341`). Thanks :user:`stas` for reporting and thanks :user:`deckar01` for the PR. - Backwards-incompatible: Don't unconditionally call callable attributes (:issue:`430`, reverts :issue:`242`). Thanks :user:`mirko` for the suggestion.
- Drop support for Python 2.6 and 3.3.
Deprecation/Removals:
- Remove
__error_handler__,__accessor__,@Schema.error_handler, and@Schema.accessor. OverrideSchema.handle_errorandSchema.get_attributeinstead. - Remove
funcparameter offields.Function. Removemethod_nameparameter offields.Method(issue:325). Use theserializeparameter instead. - Remove
extraparameter fromSchema. Use a@post_dumpmethod to add additional data.
Bug fixes:
- Don't match string-ending newlines in
URLandEmailfields (:issue:`1522`). Thanks :user:`nbanmp` for the PR.
Other changes:
- Drop support for Python 3.4 (:pr:`1525`).
Bug fixes:
- Fix behavior when a non-list collection is passed to the
validateargument offields.Emailandfields.URL(:issue:`1400`).
Bug fixes:
- Respect the
manyvalue onSchemainstances passed toNested(:issue:`1160`). Thanks :user:`Kamforka` for reporting.
Bug fixes:
- Don't swallow
TypeErrorexceptions raised byField._bind_to_schemaorSchema.on_bind_field(:pr:`1376`).
Bug fixes:
- Prevent warning about importing from
collectionson Python 3.7 (:pr:`1354`). Thanks :user:`nicktimko` for the PR.
Bug fixes:
- Fix bug that raised
TypeErrorwhen invalid data type is passed to a nested schema with@validates(:issue:`1342`).
Bug fixes:
- Fix deprecated functions' compatibility with Python 2 (:issue:`1337`). Thanks :user:`airstandley` for the catch and patch.
- Fix error message consistency for invalid input types on nested fields (:issue:`1303`). This is a backport of the fix in :pr:`857`. Thanks :user:`cristi23` for the thorough bug report and the PR.
Deprecation/Removals:
- Python 2.6 is no longer officially supported (:issue:`1274`).
Bug fixes:
- Fix deserializing ISO8601-formatted datetimes with less than 6-digit miroseconds (:issue:`1251`). Thanks :user:`diego-plan9` for reporting.
Bug fixes:
- Microseconds no longer gets lost when deserializing datetimes without dateutil installed (:issue:`1147`).
Bug fixes:
- Fix bug where nested fields in
Meta.excludewould not work on multiple instantiations (:issue:`1212`). Thanks :user:`MHannila` for reporting.
Bug fixes:
- Handle
OverflowErrorwhen (de)serializing large integers withfields.Float(:pr:`1177`). Thanks :user:`brycedrennan` for the PR.
Bug fixes:
- Fix bug where
Nested(many=True)would skip first element when serializing a generator (:issue:`1163`). Thanks :user:`khvn26` for the catch and patch.
Deprecation/Removal:
- A
RemovedInMarshmallow3warning is raised when usingfields.FormattedString. Usefields.Methodorfields.Functioninstead (:issue:`1141`).
Bug fixes:
- A
ChangedInMarshmallow3Warningis no longer raised whenstrict=False(:issue:`1108`). Thanks :user:`Aegdesil` for reporting.
Features:
- Add warnings for functions in
marshmallow.utilsthat are removed in marshmallow 3.
Bug fixes:
- Copying
missingwithcopy.copyorcopy.deepcopywill not duplicate it (:pr:`1099`).
Features:
- Add
marshmallow.__version_info__(:pr:`1074`). - Add warnings for API that is deprecated or changed to help users prepare for marshmallow 3 (:pr:`1075`).
Bug fixes:
- Prevent memory leak when dynamically creating classes with
type()(:issue:`732`). Thanks :user:`asmodehn` for writing the tests to reproduce this issue.
Bug fixes:
- Prevent warning about importing from
collectionson Python 3.7 (:issue:`1027`). Thanks :user:`nkonin` for reporting and :user:`jmargeta` for the PR.
Bug fixes:
- Remove spurious warning about implicit collection handling (:issue:`998`). Thanks :user:`lalvarezguillen` for reporting.
Bug fixes:
- Allow username without password in basic auth part of the url in
fields.Url(:pr:`982`). Thanks user:alefnula for the PR.
Other changes:
- Drop support for Python 3.3 (:pr:`987`).
Bug fixes:
- Prevent
TypeErrorwhen a non-collection is passed to aSchemawithmany=True. Instead, raiseValidationErrorwith{'_schema': ['Invalid input type.']}(:issue:`906`). - Fix
rootattribute for nested container fields on list on inheriting schemas (:issue:`956`). Thanks :user:`bmcbu` for reporting.
These fixes were backported from 3.0.0b15 and 3.0.0b16.
Bug fixes:
- Handle empty SQLAlchemy lazy lists gracefully when dumping (:issue:`948`). Thanks :user:`vke-code` for the catch and :user:`YuriHeupa` for the patch.
Bug fixes:
- Respect
load_fromwhen reporting errors for@validates('field_name')(:issue:`748`). Thanks :user:`m-novikov` for the catch and patch.
Bug fixes:
- Fix passing
onlyas a string tonestedwhen the passed field definesdump_to(:issue:`800`, :issue:`822`). Thanks :user:`deckar01` for the catch and patch.
Bug fixes:
- Fix a race condition in validation when concurrent threads use the
same
Schemainstance (:issue:`783`). Thanks :user:`yupeng0921` and :user:`lafrech` for the fix. - Fix serialization behavior of
fields.List(fields.Integer(as_string=True))(:issue:`788`). Thanks :user:`cactus` for reporting and :user:`lafrech` for the fix. - Fix behavior of
excludeparameter when passed from parent to nested schemas (:issue:`728`). Thanks :user:`timc13` for reporting and :user:`deckar01` for the fix.
Bug fixes:
- :cve:`2018-17175`: Fix behavior when an empty list is passed as the
onlyargument (:issue:`772`). Thanks :user:`deckar01` for reporting and thanks :user:`lafrech` for the fix.
Bug fixes:
- Handle
UnicodeDecodeErrorwhen deserializingbyteswith aStringfield (:issue:`650`). Thanks :user:`dan-blanchard` for the suggestion and thanks :user:`4lissonsilveira` for the PR.
Features:
- Add
require_tldparameter tovalidate.URL(:issue:`664`). Thanks :user:`sduthil` for the suggestion and the PR.
Bug fixes:
- Fix serialization of types that implement __getitem__ (:issue:`669`). Thanks :user:`MichalKononenko`.
Bug fixes:
- Fix validation of iso8601-formatted dates (:issue:`556`). Thanks :user:`lafrech` for reporting.
Bug fixes:
- Fix symmetry of serialization and deserialization behavior when passing a dot-delimited path to the
attributeparameter of fields (:issue:`450`). Thanks :user:`itajaja` for reporting.
Bug fixes:
- Restore backwards-compatibility of
SchemaOptsconstructor (:issue:`597`). Thanks :user:`Wesmania` for reporting and thanks :user:`frol` for the fix.
Bug fixes:
- Fix inheritance of
orderedoption whenSchemasubclasses defineclass Meta(:issue:`593`). Thanks :user:`frol`.
Support:
- Update contributing docs.
Bug fixes:
- Fix sorting on Schema subclasses when
ordered=True(:issue:`592`). Thanks :user:`frol`.
Features:
- Minor optimizations (:issue:`577`). Thanks :user:`rowillia` for the PR.
Bug fixes:
- Unbound fields return None rather returning the field itself. This fixes a corner case introduced in :issue:`572`. Thanks :user:`touilleMan` for reporting and :user:`YuriHeupa` for the fix.
Bug fixes:
- Fix behavior when a
Nestedfield is composed within aListfield (:issue:`572`). Thanks :user:`avish` for reporting and :user:`YuriHeupa` for the PR.
Features:
- Allow passing nested attributes (e.g.
'child.field') to thedump_onlyandload_onlyparameters ofSchema(:issue:`572`). Thanks :user:`YuriHeupa` for the PR. - Add
schemesparameter tofields.URL(:issue:`574`). Thanks :user:`mosquito` for the PR.
Bug fixes:
- Allow
strictclass Meta option to be overridden by constructor (:issue:`550`). Thanks :user:`douglas-treadwell` for reporting and thanks :user:`podhmo` for the PR.
Features:
- Import
marshmallow.fieldsinmarshmallow/__init__.pyto save an import when importing themarshmallowmodule (:issue:`557`). Thanks :user:`mindojo-victor`.
Support:
- Documentation: Improve example in "Validating Original Input Data" (:issue:`558`). Thanks :user:`altaurog`.
- Test against Python 3.6.
Bug fixes:
- Reset user-defined kwargs passed to
ValidationErroron eachSchema.loadcall (:issue:`565`). Thanks :user:`jbasko` for the catch and patch.
Support:
- Tests: Fix redefinition of
test_utils.test_get_value()(:issue:`562`). Thanks :user:`nelfin`.
Bug fixes:
- Function field works with callables that use Python 3 type annotations (:issue:`540`). Thanks :user:`martinstein` for reporting and thanks :user:`sabinem`, :user:`lafrech`, and :user:`maximkulkin` for the work on the PR.
Bug fixes:
- Fix behavior for serializing missing data with
Numberfields whenas_string=Trueis passed (:issue:`538`). Thanks :user:`jessemyers` for reporting.
Bug fixes:
- Use fixed-point notation rather than engineering notation when serializing with
Decimal(:issue:`534`). Thanks :user:`gdub`. - Fix UUID validation on serialization and deserialization of
uuid.UUIDobjects (:issue:`532`). Thanks :user:`pauljz`.
Bug fixes:
- Fix behavior when using
validate.Equal(False)(:issue:`484`). Thanks :user:`pktangyue` for reporting and thanks :user:`tuukkamustonen` for the fix. - Fix
strictbehavior when errors are raised inpre_dump/post_dumpprocessors (:issue:`521`). Thanks :user:`tvuotila` for the catch and patch. - Fix validation of nested fields on dumping (:issue:`528`). Thanks again :user:`tvuotila`.
Features:
- Errors raised by pre/post-load/dump methods will be added to a schema's errors dictionary (:issue:`472`). Thanks :user:`dbertouille` for the suggestion and for the PR.
Bug fixes:
- Fix serialization of
datetime.timeobjects with microseconds (:issue:`464`). Thanks :user:`Tim-Erwin` for reporting and thanks :user:`vuonghv` for the fix. - Make
@validatesconsistent with field validator behavior: if validation fails, the field will not be included in the deserialized output (:issue:`391`). Thanks :user:`martinstein` for reporting and thanks :user:`vuonghv` for the fix.
Decimalfield coerces input values to a string before deserializing to a decimal.Decimal object in order to avoid transformation of float values under 12 significant digits (:issue:`434`, :issue:`435`). Thanks :user:`davidthornton` for the PR.
Features:
- Allow
onlyandexcludeparameters to take nested fields, using dot-delimited syntax (e.g.only=['blog.author.email']) (:issue:`402`). Thanks :user:`Tim-Erwin` and :user:`deckar01` for the discussion and implementation.
Support:
- Update tasks.py for compatibility with invoke>=0.13.0. Thanks :user:`deckar01`.
- Make
field.parentandfield.nameaccessible toon_bind_field(:issue:`449`). Thanks :user:`immerrr`.
No code changes in this release. This is a reupload in order to distribute an sdist for the last hotfix release. See :issue:`443`.
Support:
- Update license entry in setup.py to fix RPM distributions (:issue:`433`). Thanks :user:`rrajaravi` for reporting.
Bug fixes:
- Only add Schemas to class registry if a class name is provided. This allows Schemas to be
constructed dynamically using the
typeconstructor without getting added to the class registry (which is useful for saving memory).
Features:
- Make context available to
Nestedfield'son_bind_fieldmethod (:issue:`408`). Thanks :user:`immerrr` for the PR. - Pass through user
ValidationErrorkwargs (:issue:`418`). Thanks :user:`russelldavies` for helping implement this.
Other changes:
- Remove unused attributes
root,parent, andnamefromSchemaABC(:issue:`410`). Thanks :user:`Tim-Erwin` for the PR.
Bug fixes:
- Respect
load_fromwhen reporting errors for nested required fields (:issue:`414`). Thanks :user:`yumike`.
Features:
- Add
partialargument toSchema.validate(:issue:`379`). Thanks :user:`tdevelioglu` for the PR. - Add
equalargument tovalidate.Length. Thanks :user:`daniloakamine`. - Collect all validation errors for each item deserialized by a
Listfield (:issue:`345`). Thanks :user:`maximkulkin` for the report and the PR.
Features:
- Allow a tuple of field names to be passed as the
partialargument toSchema.load(:issue:`369`). Thanks :user:`tdevelioglu` for the PR. - Add
schemesargument tovalidate.URL(:issue:`356`).
Bug fixes:
- Prevent duplicate error messages when validating nested collections (:issue:`360`). Thanks :user:`alexmorken` for the catch and patch.
Bug fixes:
- Serializing an iterator will not drop the first item (:issue:`343`, :issue:`353`). Thanks :user:`jmcarp` for the patch. Thanks :user:`edgarallang` and :user:`jmcarp` for reporting.
Features:
- Add
skip_on_field_errorsparameter tovalidates_schema(:issue:`323`). Thanks :user:`jjvattamattom` for the suggestion and :user:`d-sutherland` for the PR.
Bug fixes:
- Fix
FormattedStringserialization (:issue:`348`). Thanks :user:`acaird` for reporting. - Fix
@validatesbehavior when used whenattributeis specified andstrict=True(:issue:`350`). Thanks :user:`density` for reporting.
Features:
- Add
dump_toparameter to fields (:issue:`310`). Thanks :user:`ShayanArmanPercolate` for the suggestion. Thanks :user:`franciscod` and :user:`ewang` for the PRs. - The
deserializefunction passed tofields.Functioncan optionally receive acontextargument (:issue:`324`). Thanks :user:`DamianHeard`. - The
serializefunction passed tofields.Functionis optional (:issue:`325`). Thanks again :user:`DamianHeard`. - The
serializefunction passed tofields.Methodis optional (:issue:`329`). Thanks :user:`justanr`.
Deprecation/Removal:
- The
funcargument offields.Functionhas been renamed toserialize. - The
method_nameargument offields.Methodhas been renamed toserialize.
func and method_name are still present for backwards-compatibility, but they will both be removed in marshmallow 3.0.
Bug fixes:
- Skip field validators for fields that aren't included in
only(:issue:`320`). Thanks :user:`carlos-alberto` for reporting and :user:`eprikazc` for the PR.
Features:
- Add support for partial deserialization with the
partialargument toSchemaandSchema.load(:issue:`290`). Thanks :user:`taion`.
Deprecation/Removals:
QueryandQuerySelectfields are removed.- Passing of strings to
requiredandallow_noneis removed. Pass theerror_messagesargument instead.
Support:
- Add example of Schema inheritance in docs (:issue:`225`). Thanks :user:`martinstein` for the suggestion and :user:`juanrossi` for the PR.
- Add "Customizing Error Messages" section to custom fields docs.
Bug fixes:
- Fix serialization of collections for which
iterwill modify position, e.g. Pymongo cursors (:issue:`303`). Thanks :user:`Mise` for the catch and patch.
Bug fixes:
- Fix passing data to schema validator when using
@validates_schema(many=True)(:issue:`297`). Thanks :user:`d-sutherland` for reporting. - Fix usage of
@validateswith a nested field whenmany=True(:issue:`298`). Thanks :user:`nelfin` for the catch and patch.
Bug fixes:
Constantfield deserializes to its value regardless of whether its field name is present in input data (:issue:`291`). Thanks :user:`fayazkhan` for reporting.
Features:
- Add
Dictfield for arbitrary mapping data (:issue:`251`). Thanks :user:`dwieeb` for adding this and :user:`Dowwie` for the suggestion. - Add
Field.rootproperty, which references the field's Schema.
Deprecation/Removals:
- The
extraparam ofSchemais deprecated. Add extra data in apost_loadmethod instead. UnmarshallingErrorandMarshallingErrorare removed.
Bug fixes:
- Fix storing multiple schema-level validation errors (:issue:`287`). Thanks :user:`evgeny-sureev` for the patch.
- If
missing=Noneon a field,allow_nonewill be set toTrue.
Other changes:
- A
List'sinner field will have the list field set as its parent. Userootto access theSchema.
Features:
- Make error messages configurable at the class level and instance level (
Field.default_error_messagesattribute anderror_messagesparameter, respectively).
Deprecation/Removals:
- Remove
make_object. Use apost_loadmethod instead (:issue:`277`). - Remove the
errorparameter and attribute ofField. - Passing string arguments to
requiredandallow_noneis deprecated. Pass theerror_messagesargument instead. This API will be removed in version 2.2. - Remove
Arbitrary,Fixed, andPricefields (:issue:`86`). UseDecimalinstead. - Remove
Select/Enumfields (:issue:`135`). Use theOneOfvalidator instead.
Bug fixes:
- Fix error format for
Nestedfields whenmany=True. Thanks :user:`alexmorken`. pre_dumpmethods are invoked before implicit field creation. Thanks :user:`makmanalp` for reporting.- Return correct "required" error message for
Nestedfield. - The
onlyargument passed to aSchemais bounded by thefieldsoption (:issue:`183`). Thanks :user:`lustdante` for the suggestion.
Changes from 2.0.0rc2:
error_handlerandaccessoroptions are replaced with thehandle_errorandget_attributemethods :issue:`284`.- Remove
marshmallow.compat.plain_functionsince it is no longer used. - Non-collection values are invalid input for
Listfield (:issue:`231`). Thanks :user:`density` for reporting. - Bug fix: Prevent infinite loop when validating a required, self-nested field. Thanks :user:`Bachmann1234` for the fix.
Deprecation/Removals:
make_objectis deprecated. Use apost_loadmethod instead (:issue:`277`). This method will be removed in the final 2.0 release.Schema.accessorandSchema.error_handlerdecorators are deprecated. Define theaccessoranderror_handlerclass Meta options instead.
Bug fixes:
- Allow non-field names to be passed to
ValidationError(:issue:`273`). Thanks :user:`evgeny-sureev` for the catch and patch.
Changes from 2.0.0rc1:
- The
rawparameter of thepre_*,post_*,validates_schemadecorators was renamed topass_many(:issue:`276`). - Add
pass_originalparameter topost_loadandpost_dump(:issue:`216`). - Methods decorated with the
pre_*,post_*, andvalidates_*decorators must be instance methods. Class methods and instance methods are not supported at this time.
Features:
- Backwards-incompatible:
fields.Field._deserializenow takesattranddataas arguments (:issue:`172`). Thanks :user:`alexmic` and :user:`kevinastone` for the suggestion. - Allow a
Field'sattributeto be modified during deserialization (:issue:`266`). Thanks :user:`floqqi`. - Allow partially-valid data to be returned for
Nestedfields (:issue:`269`). Thanks :user:`jomag` for the suggestion. - Add
Schema.on_bind_fieldhook which allows aSchemato modify its fields when they are bound. - Stricter validation of string, boolean, and number fields (:issue:`231`). Thanks :user:`touilleMan` for the suggestion.
- Improve consistency of error messages.
Deprecation/Removals:
Schema.validator,Schema.preprocessor, andSchema.data_handlerare removed. Usevalidates_schema,pre_load, andpost_dumpinstead.QuerySelectandQuerySelectListare deprecated (:issue:`227`). These fields will be removed in version 2.1.utils.get_callable_nameis removed.
Bug fixes:
- If a date format string is passed to a
DateTimefield, it is always used for deserialization (:issue:`248`). Thanks :user:`bartaelterman` and :user:`praveen-p`.
Support:
- Documentation: Add "Using Context" section to "Extending Schemas" page (:issue:`224`).
- Include tests and docs in release tarballs (:issue:`201`).
- Test against Python 3.5.
Features:
- If a field corresponds to a callable attribute, it will be called upon serialization. Thanks :user:`alexmorken`.
- Add
load_onlyanddump_onlyclass Metaoptions. Thanks :user:`kelvinhammond`. - If a
Nestedfield is required, recursively validate any required fields in the nested schema (:issue:`235`). Thanks :user:`max-orhai`. - Improve error message if a list of dicts is not passed to a
Nestedfield for whichmany=True. Thanks again :user:`max-orhai`.
Bug fixes:
make_objectis only called after all validators and postprocessors have finished (:issue:`253`). Thanks :user:`sunsongxp` for reporting.- If an invalid type is passed to
Schemaandstrict=False, store a_schemaerror in the errors dict rather than raise an exception (:issue:`261`). Thanks :user:`density` for reporting.
Other changes:
make_objectis only called when input data are completely valid (:issue:`243`). Thanks :user:`kissgyorgy` for reporting.- Change default error messages for
URLandEmailvalidators so that they don't include user input (:issue:`255`). Emailvalidator permits email addresses with non-ASCII characters, as per RFC 6530 (:issue:`221`). Thanks :user:`lextoumbourou` for reporting and :user:`mwstobo` for sending the patch.
Features:
Listfield respects theattributeargument of the inner field. Thanks :user:`jmcarp`.- The
containerfieldListfield has access to its parentSchemavia itsparentattribute. Thanks again :user:`jmcarp`.
Deprecation/Removals:
- Legacy validator functions have been removed (:issue:`73`). Use the class-based validators in
marshmallow.validateinstead.
Bug fixes:
fields.Nestedcorrectly serializes nestedsets(:issue:`233`). Thanks :user:`traut`.
Changes from 2.0.0b3:
- If
load_fromis used on deserialization, the value ofload_fromis used as the key in the errors dict (:issue:`232`). Thanks :user:`alexmorken`.
Features:
- Add
marshmallow.validates_schemadecorator for defining schema-level validators (:issue:`116`). - Add
marshmallow.validatesdecorator for defining field validators as Schema methods (:issue:`116`). Thanks :user:`philtay`. - Performance improvements.
- Defining
__marshallable__on complex objects is no longer necessary. - Add
fields.Constant. Thanks :user:`kevinastone`.
Deprecation/Removals:
- Remove
skip_missingclass Meta option. By default, missing inputs are excluded from serialized output (:issue:`211`). - Remove optional
contextparameter that gets passed to methods forMethodfields. Schema.validatoris deprecated. Usemarshmallow.validates_schemainstead.utils.get_func_nameis removed. Useutils.get_callable_nameinstead.
Bug fixes:
- Fix serializing values from keyed tuple types (regression of :issue:`28`). Thanks :user:`makmanalp` for reporting.
Other changes:
- Remove unnecessary call to
utils.get_valueforFunctionandMethodfields (:issue:`208`). Thanks :user:`jmcarp`. - Serializing a collection without passing
many=Truewill not result in an error. Be very careful to pass themanyargument when necessary.
Support:
- Documentation: Update Flask and Peewee examples. Update Quickstart.
Changes from 2.0.0b2:
Booleanfield serializesNonetoNone, for consistency with other fields (:issue:`213`). Thanks :user:`cmanallen` for reporting.- Bug fix:
load_onlyfields do not get validated during serialization. - Implicit passing of original, raw data to Schema validators is removed. Use
@marshmallow.validates_schema(pass_original=True)instead.
Features:
- Add useful
__repr__methods to validators (:issue:`204`). Thanks :user:`philtay`. - Backwards-incompatible: By default,
NaN,Infinity, and-Infinityare invalid values forfields.Decimal. Passallow_nan=Trueto allow these values. Thanks :user:`philtay`.
Changes from 2.0.0b1:
- Fix serialization of
NoneforTime,TimeDelta, andDatefields (a regression introduced in 2.0.0a1).
Includes bug fixes from 1.2.6.
Features:
- Errored fields will not appear in (de)serialized output dictionaries (:issue:`153`, :issue:`202`).
- Instantiate
OPTIONS_CLASSinSchemaMeta. This makesSchema.optsavailable in metaclass methods. It also causes validation to occur earlier (uponSchemaclass declaration rather than instantiation). - Add
SchemaMeta.get_declared_fieldsclass method to support adding additional declared fields.
Deprecation/Removals:
- Remove
allow_nullparameter offields.Nested(:issue:`203`).
Changes from 2.0.0a1:
- Fix serialization of None for
fields.Email.
Features:
- Backwards-incompatible: When
many=True, the errors dictionary returned bydumpandloadwill be keyed on the indices of invalid items in the (de)serialized collection (:issue:`75`). Addindex_errors=Falseon a Schema'sclass Metaoptions to disable this behavior. - Backwards-incompatible: By default, fields will raise a ValidationError if the input is
None. Theallow_noneparameter can override this behavior. - Backwards-incompatible: A
Field'sdefaultparameter is only used if explicitly set and the field's value is missing in the input to Schema.dump. If not set, the key will not be present in the serialized output for missing values . This is the behavior for all fields.fields.Strno longer defaults to'',fields.Intno longer defaults to0, etc. (:issue:`199`). Thanks :user:`jmcarp` for the feedback. - In
strictmode, aValidationErroris raised. Error messages are accessed via theValidationError'smessagesattribute (:issue:`128`). - Add
allow_noneparameter tofields.Field. IfFalse(the default), validation fails when the field's value isNone(:issue:`76`, :issue:`111`). Ifallow_noneisTrue,Noneis considered valid and will deserialize toNone. - Schema-level validators can store error messages for multiple fields (:issue:`118`). Thanks :user:`ksesong` for the suggestion.
- Add
pre_load,post_load,pre_dump, andpost_dumpSchema method decorators for defining pre- and post- processing routines (:issue:`153`, :issue:`179`). Thanks :user:`davidism`, :user:`taion`, and :user:`jmcarp` for the suggestions and feedback. Thanks :user:`taion` for the implementation. - Error message for
requiredvalidation is configurable. (:issue:`78`). Thanks :user:`svenstaro` for the suggestion. Thanks :user:`0xDCA` for the implementation. - Add
load_fromparameter to fields (:issue:`125`). Thanks :user:`hakjoon`. - Add
load_onlyanddump_onlyparameters to fields (:issue:`61`, :issue:`87`). Thanks :user:`philtay`. - Add missing parameter to fields (:issue:`115`). Thanks :user:`philtay`.
- Schema validators can take an optional
raw_dataargument which contains raw input data, incl. data not specified in the schema (:issue:`127`). Thanks :user:`ryanlowe0`. - Add
validate.OneOf(:issue:`135`) andvalidate.ContainsOnly(:issue:`149`) validators. Thanks :user:`philtay`. - Error messages for validators can be interpolated with {input} and other values (depending on the validator).
fields.TimeDeltaalways serializes to an integer value in order to avoid rounding errors (:issue:`105`). Thanks :user:`philtay`.- Add
includeclass Meta option to support field names which are Python keywords (:issue:`139`). Thanks :user:`nickretallack` for the suggestion. excludeparameter is respected when used together withonlyparameter (:issue:`165`). Thanks :user:`lustdante` for the catch and patch.fields.Listworks as expected with generators and sets (:issue:`185`). Thanks :user:`sergey-aganezov-jr`.
Deprecation/Removals:
MarshallingErrorandUnmarshallingErrorerror are deprecated in favor of a singleValidationError(:issue:`160`).contextargument passed to Method fields is deprecated. Useself.contextinstead (:issue:`184`).- Remove
ForcedError. - Remove support for generator functions that yield validators (:issue:`74`). Plain generators of validators are still supported.
- The
Select/Enumfield is deprecated in favor of usingvalidate.OneOfvalidator (:issue:`135`). - Remove legacy, pre-1.0 API (
Schema.dataandSchema.errorsproperties) (:issue:`73`). - Remove
nullvalue.
Other changes:
Marshaller,Unmarshallerwere moved tomarshmallow.marshalling. These should be considered private API (:issue:`129`).- Make
allow_null=Truethe default forNestedfields. This will makeNoneserialize toNonerather than a dictionary with empty values (:issue:`132`). Thanks :user:`nickrellack` for the suggestion.
Bug fixes:
- Fix validation error message for
fields.Decimal. - Allow error message for
fields.Booleanto be customized with theerrorparameter (like other fields).
Bug fixes:
- Fix validation of invalid types passed to a
Nestedfield whenmany=True(:issue:`188`). Thanks :user:`juanrossi` for reporting.
Support:
- Fix pep8 dev dependency for flake8. Thanks :user:`taion`.
Bug fixes:
- Fix behavior of
as_stringonfields.Integer(:issue:`173`). Thanks :user:`taion` for the catch and patch.
Other changes:
- Remove dead code from
fields.Field. Thanks :user:`taion`.
Support:
- Correction to
_postprocessmethod in docs. Thanks again :user:`taion`.
Bug fixes:
- Fix inheritance of
orderedclass Meta option (:issue:`162`). Thanks :user:`stephenfin` for reporting.
Bug fixes:
- Fix behavior of
skip_missingandaccessoroptions whenmany=True(:issue:`137`). Thanks :user:`3rdcycle`. - Fix bug that could cause an
AttributeErrorwhen nesting schemas with schema-level validators (:issue:`144`). Thanks :user:`vovanbo` for reporting.
Bug fixes:
- A
Schema'serror_handler--if defined--will execute ifSchema.validatereturns validation errors (:issue:`121`). - Deserializing None returns None rather than raising an
AttributeError(:issue:`123`). Thanks :user:`RealSalmon` for the catch and patch.
Features:
- Add
QuerySelectandQuerySelectListfields (:issue:`84`). - Convert validators in
marshmallow.validateinto class-based callables to make them easier to use when declaring fields (:issue:`85`). - Add
Decimalfield which is safe to use when dealing with precise numbers (:issue:`86`).
Thanks :user:`philtay` for these contributions.
Bug fixes:
Datefields correctly deserializes to adatetime.dateobject whenpython-dateutilis not installed (:issue:`79`). Thanks :user:`malexer` for the catch and patch.- Fix bug that raised an
AttributeErrorwhen using a class-based validator. - Fix
as_stringbehavior of Number fields when serializing to default value. - Deserializing
Noneor the empty string with either aDateTime,Date,TimeorTimeDeltaresults in the correct unmarshalling errors (:issue:`96`). Thanks :user:`svenstaro` for reporting and helping with this. - Fix error handling when deserializing invalid UUIDs (:issue:`106`). Thanks :user:`vesauimonen` for the catch and patch.
Schema.loadscorrectly defaults to use the value ofself.manyrather than defaulting toFalse(:issue:`108`). Thanks :user:`davidism` for the catch and patch.- Validators, data handlers, and preprocessors are no longer shared between schema subclasses (:issue:`88`). Thanks :user:`amikholap` for reporting.
- Fix error handling when passing a
dictorlistto aValidationError(:issue:`110`). Thanks :user:`ksesong` for reporting.
Deprecation:
- The validator functions in the
validatemodule are deprecated in favor of the class-based validators (:issue:`85`). - The
Arbitrary,Price, andFixedfields are deprecated in favor of theDecimalfield (:issue:`86`).
Support:
- Update docs theme.
- Update contributing docs (:issue:`77`).
- Fix namespacing example in "Extending Schema" docs. Thanks :user:`Ch00k`.
- Exclude virtualenv directories from syntax checking (:issue:`99`). Thanks :user:`svenstaro`.
Features:
- Add
Schema.validatemethod which validates input data against a schema. Similar toSchema.load, but does not callmake_objectand only returns the errors dictionary. - Add several validation functions to the
validatemodule. Thanks :user:`philtay`. - Store field name and instance on exceptions raised in
strictmode.
Bug fixes:
- Fix serializing dictionaries when field names are methods of
dict(e.g."items"). Thanks :user:`rozenm` for reporting. - If a Nested field is passed
many=True,Noneserializes to an empty list. Thanks :user:`nickretallack` for reporting. - Fix behavior of
manyargument passed todumpandload. Thanks :user:`svenstaro` for reporting and helping with this. - Fix
skip_missingbehavior forStringandListfields. Thanks :user:`malexer` for reporting. - Fix compatibility with python-dateutil 2.3.
- More consistent error messages across
DateTime,TimeDelta,Date, andTimefields.
Support:
- Update Flask and Peewee examples.
Hotfix release.
- Ensure that errors dictionary is correctly cleared on each call to
Schema.dumpandSchema.load.
Adds new features, speed improvements, better error handling, and updated documentation.
- Add
skip_missingclass Metaoption. - A field's
defaultmay be a callable. - Allow accessor function to be configured via the
Schema.accessordecorator or the__accessor__class member. URLandEmailfields are validated upon serialization.dumpandloadcan receive themanyargument.- Move a number of utility functions from fields.py to utils.py.
- More useful
reprforFieldclasses. - If a field's default is
fields.missingand its serialized value isNone, it will not be included in the final serialized result. - Schema.dumps no longer coerces its result to a binary string on Python 3.
- Backwards-incompatible: Schema output is no longer an
OrderedDictby default. If you want ordered field output, you must explicitly set theorderedoption toTrue. - Backwards-incompatible:
errorparameter of theFieldconstructor is deprecated. Raise aValidationErrorinstead. - Expanded test coverage.
- Updated docs.
Major reworking and simplification of the public API, centered around support for deserialization, improved validation, and a less stateful Schema class.
- Rename
SerializertoSchema. - Support for deserialization.
- Use the
Schema.dumpandSchema.loadmethods for serializing and deserializing, respectively. - Backwards-incompatible: Remove
Serializer.jsonandSerializer.to_json. UseSchema.dumpsinstead. - Reworked fields interface.
- Backwards-incompatible:
Fieldclasses implement_serializeand_deserializemethods.serializeanddeserializecomprise the public API for aField.Field.formatandField.outputhave been removed. - Add
exceptions.ForcedErrorwhich allows errors to be raised during serialization (instead of storing errors in theerrorsdict). - Backwards-incompatible:
DateTimefield serializes to ISO8601 format by default (instead of RFC822). - Backwards-incompatible: Remove
Serializer.factorymethod. It is no longer necessary with thedumpmethod. - Backwards-incompatible: Allow nesting a serializer within itself recursively. Use
excludeoronlyto prevent infinite recursion. - Backwards-incompatible: Multiple errors can be stored for a single field. The errors dictionary returned by
loadanddumphave lists of error messages keyed by field name. - Remove
validateddecorator. Validation occurs withinFieldmethods. Functionfield raises aValueErrorif an uncallable object is passed to its constructor.Nestedfields inherit context from their parent.- Add
Schema.preprocessorandSchema.validatordecorators for registering preprocessing and schema-level validation functions respectively. - Custom error messages can be specified by raising a
ValidationErrorwithin a validation function. - Extra keyword arguments passed to a Field are stored as metadata.
- Fix ordering of field output.
- Fix behavior of the
requiredparameter onNestedfields. - Fix serializing keyed tuple types (e.g.
namedtuple) withclass Metaoptions. - Fix default value for
FixedandPricefields. - Fix serialization of binary strings.
Schemascan inherit fields from non-Schemabase classes (e.g. mixins). Also, fields are inherited according to the MRO (rather than recursing over base classes). Thanks :user:`jmcarp`.- Add
Str,Bool, andIntfield class aliases.
- Add
Serializer.error_handlerdecorator that registers a custom error handler. - Add
Serializer.data_handlerdecorator that registers data post-processing callbacks. - Backwards-incompatible:
process_datamethod is deprecated. Use thedata_handlerdecorator instead. - Fix bug that raised error when passing
extradata together withmany=True. Thanks :user:`buttsicles` for reporting. - If
required=Truevalidation is violated for a givenField, it will raise an error message that is different from the message specified by theerrorargument. Thanks :user:`asteinlein`. - More generic error message raised when required field is missing.
validateddecorator should only wrap aFieldclass'soutputmethod.
- Fix bug in serializing keyed tuple types, e.g.
namedtupleandKeyedTuple. - Nested field can load a serializer by its class name as a string. This makes it easier to implement 2-way nesting.
- Make
Serializer.dataoverride-able.
- Add
Serializer.factoryfor creating a factory function that returns a Serializer instance. MarshallingErrorstores its underlying exception as an instance variable. This is useful for inspecting errors.fields.Selectis aliased tofields.Enum.- Add
fields.__all__andmarshmallow.__all__so that the modules can be more easily extended. - Expose
Serializer.OPTIONS_CLASSas a class variable so that options defaults can be overridden. - Add
Serializer.process_datahook that allows subclasses to manipulate the final output data.
- Add
json_moduleclass Meta option. - Add
requiredoption to fields . Thanks :user:`DeaconDesperado`. - Tested on Python 3.4 and PyPy.
- Fix
Integerfield default. It is now0instead of0.0. Thanks :user:`kalasjocke`. - Add
contextparam toSerializer. Allows accessing arbitrary objects inFunctionandMethodfields. FunctionandMethodfields raiseMarshallingErrorif their argument is uncallable.
- Enable custom field validation via the
validateparameter. - Add
utils.from_rfcfor parsing RFC datestring to Python datetime object.
- Avoid unnecessary attribute access in
utils.to_marshallable_typefor improved performance. - Fix RFC822 formatting for localized datetimes.
- Can customize validation error messages by passing the
errorparameter to a field. - Backwards-incompatible: Rename
fields.NumberField->fields.Number. - Add
fields.Select. Thanks :user:`ecarreras`. - Support nesting a Serializer within itself by passing
"self"intofields.Nested(only up to depth=1). - Backwards-incompatible: No implicit serializing of collections. Must set
many=Trueif serializing to a list. This ensures that marshmallow handles singular objects correctly, even if they are iterable. - If Nested field
onlyparameter is a field name, only return a single value for the nested object (instead of a dict) or a flat list of values. - Improved performance and stability.
- An object's
__marshallable__method, if defined, takes precedence over__getitem__. - Generator expressions can be passed to a serializer.
- Better support for serializing list-like collections (e.g. ORM querysets).
- Other minor bugfixes.
- Add
additionalclass Meta option. - Add
dateformatclass Meta option. - Support for serializing UUID, date, time, and timedelta objects.
- Remove
Serializer.to_datamethod. Just useSerialize.dataproperty. - String field defaults to empty string instead of
None. - Backwards-incompatible:
isoformatandrfcformatfunctions moved to utils.py. - Backwards-incompatible: Validation functions moved to validate.py.
- Backwards-incompatible: Remove types.py.
- Reorder parameters to
DateTimefield (first parameter is dateformat). - Ensure that
to_jsonreturns bytestrings. - Fix bug with including an object property in
fieldsMeta option. - Fix bug with passing
Noneto a serializer.
- Fix bug with serializing dictionaries.
- Fix error raised when serializing empty list.
- Add
onlyandexcludeparameters to Serializer constructor. - Add
strictparameter and option: causes Serializer to raise an error if invalid data are passed in, rather than storing errors. - Updated Flask + SQLA example in docs.
- Declaring Serializers just got easier. The
class Metaparadigm allows you to specify fields more concisely. Can specifyfieldsandexcludeoptions. - Allow date formats to be changed by passing
formatparameter toDateTimefield constructor. Can either be"rfc"(default),"iso", or a date format string. - More useful error message when declaring fields as classes (instead of an instance, which is the correct usage).
- Rename
MarshallingException->MarshallingError. - Rename
marshmallow.core->marshmallow.serializer.
- Allow prefixing field names.
- Fix storing errors on Nested Serializers.
- Python 2.6 support.
- Field-level validation.
- Add
fields.Method. - Add
fields.Function. - Allow binding of extra data to a serialized object by passing the
extraparam when initializing aSerializer. - Add
relativeparameter tofields.Urlthat allows for relative URLs.
- First release.