See also
Need help upgrading to newer versions? Check out the upgrading guide.
Changelog¶
4.0.0 (unreleased)¶
See Upgrading to 4.0 for a guide on updating your code.
Features:
Typing: Add types to all
Field
constructor kwargs (#2285). Thanks @navignaw for the suggestion.DateTime
,Date
,Time
,TimeDelta
, andEnum
accept their internal value types as valid input (#1415). Thanks @bitdancer for the suggestion.@validates
accepts multiple field names (#1960). Backwards-incompatible: Decorated methods now receivedata_key
as a keyword argument. Thanks @dpriskorn for the suggestion and @dharani7998 for the PR.
Other changes:
Typing:
Field
is now a generic type with a type argument for the internal value type.marshmallow.fields.UUID
no longer subclassesmarshmallow.fields.String
.Backwards-incompatible: Use
datetime.date.fromisoformat
,datetime.time.fromisoformat
, anddatetime.datetime.fromisoformat
from the standard library to deserialize dates, times and datetimes (#2078).marshmallow.Schema.load
no longer silently fails to call schema validators when a generator is passed (#1898). The typing ofdata
is also updated to be more accurate. Thanks @ziplokk1 for reporting.
- 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
andfrom_iso_datetime
are removed frommarshmallow.utils
.
Remove
isoformat
,to_iso_time
andto_iso_datetime
frommarshmallow.utils
(#2766).Remove
from_rfc
, andrfcformat
frommarshmallow.utils
(#2767).Remove
is_keyed_tuple
frommarshmallow.utils
(#2768).Remove
get_fixed_timezone
frommarshmallow.utils
(#2773).Backwards-incompatible:
marshmallow.fields.Boolean
no longer serializes non-boolean values (#2725).Backwards-incompatible: Rename
schema
parameter toparent
inmarshmallow.fields.Field._bind_to_schema
(#1360).Backwards-incompatible: Rename
pass_many
parameter topass_collection
in pre/post processing methods (#1369).Backwards-incompatible:
marshmallow.fields.TimeDelta
no longer truncates float values when deserializing (#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 (#2654).Backwards-incompatible: Remove
serialization_type
parameter frommarshmallow.fields.TimeDelta
(#2654).
Thanks @ddelange for the PR.
Backwards-incompatible: Remove
Schema
’scontext
attribute (deprecated since 3.24.0). Passing a context should be done usingcontextvars.ContextVar
(#1826). marshmallow 4 provides an experimentalContext
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
, receiveunknown
as a keyword argument (#1632). Thanks @jforand for the PR.Backwards-incompatible: Arguments to
decorators
are keyword-only arguments.Backwards-incompatible: Rename
json_data
parameter ofmarshmallow.Schema.loads
tos
for compatibility with most render module implementations (json
,simplejson
, etc.) (#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) (#2772).
Passing invalid values for
unknown
will cause an error in type checkers (#2771).
Deprecations/Removals:
Backwards-incompatible: Remove implicit field creation, i.e. using the
fields
oradditional
class Meta options with undeclared fields (#1356).The
ordered
class Meta option is removed (#2146). Field order is already preserved by default. SetSchema.dict_class
toOrderedDict
to maintain the previous behavior.The
marshmallow.base
module is removed (#2722).
Previously-deprecated APIs have been removed, including:
The
ordered
class Meta
option is removed (#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). Usemarshmallow.fields.Integer
,marshmallow.fields.Float
, ormarshmallow.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
for invalid values (deprecated in 3.24.0). ReturningFalse
is no longer supported (#1775). Usemarshmallow.fields.Dict
instead.Remove
__version__
,__parsed_version__
, and__version_info__
attributes (deprecated in 3.21.0).default
andmissing
parameters, which were replaced bydump_default
andload_default
in 3.13.0 (#1742, #2700).Passing field metadata via keyword arguments (deprecated in 3.10.0). Use the explicit
metadata=...
argument instead (#1350).marshmallow.utils.pprint
(deprecated in 3.7.0). Usepprint.pprint
instead.Passing
"self"
tofields.Nested
(deprecated in 3.3.0). Use a callable instead.Field.fail
, which was replaced byField.make_error
in 3.0.0.json_module
class Meta option (deprecated in 3.0.0b3). Userender_module
instead.
3.26.1 (2025-02-03)¶
Bug fixes:
Typing: Fix type annotations for
class Meta
options (#2804). Thanks @lawrence-law for reporting.
Other changes:
3.26.0 (2025-01-22)¶
Features:
Typing: Add type annotations and improved documentation for
class Meta
options (#2760).Typing: Improve type coverage of
marshmallow.Schema.SchemaMeta
(#2761).Typing:
marshmallow.Schema.loads
parameter allowsbytes
andbytesarray
(#2769).
Bug fixes:
Respect
data_key
when schema validators raise aValidationError
with afield_name
argument (#2170). Thanks @matejsp for reporting.Correctly handle multiple
@post_load
methods where one method appends to the data and another passespass_original=True
(#1755). Thanks @ghostwheel42 for reporting.URL
fields now properly validatefile
paths (#2249). Thanks @0xDEC0DE for reporting and fixing.
Documentation:
Add upgrading guides for 3.24 and 3.26 (#2780).
Various documentation improvements (#2757, #2759, #2765, #2774, #2778, #2783, #2796).
Deprecations:
The
ordered
class Meta
option is deprecated (#2146, #2762). Field order is already preserved by default. Setmarshmallow.Schema.dict_class
tocollections.OrderedDict
to maintain the previous behavior.
3.25.1 (2025-01-11)¶
Bug fixes:
Typing: Fix type annotations for
Tuple
,Boolean
, andPluck
constructors (#2756).Typing: Fix overload for
marshmallow.class_registry.get_class
(#2756).
Documentation:
3.25.0 (2025-01-09)¶
Features:
Typing: Improve type annotations for
SchemaMeta.get_declared_fields
(#2742).
Bug fixes:
Typing: Relax type annotation for
Schema.opts
to allow subclasses to define their own options classes (#2744).
Other changes:
Restore
marshmallow.base.SchemaABC
for backwards-compatibility (#2743). Note that this class is deprecated and will be removed in marshmallow 4. Usemarshmallow.schema.Schema
as a base class for type-checking instead.
3.24.2 (2025-01-08)¶
Changes:
Don’t override
__new__
to avoid breaking usages ofinspect.signature
withField
classes. This allows marshmallow-sqlalchemy users to upgrade marshmallow without upgrading to marshmallow-sqlalchemy>=1.1.1.
Documentation:
3.24.1 (2025-01-06)¶
Bug fixes:
Typing: Fix typing for
class_registry.get_class
(#2735).
3.24.0 (2025-01-06)¶
Features:
Typing: Improve typings in
marshmallow.fields
(#2723).Typing: Replace type comments with inline typings (#2718).
Bug fixes:
Deprecations:
Custom validators should raise a
ValidationError
for invalid values. ReturningFalse`
is no longer supported .Deprecate
context
parameter ofSchema
(#1826). UsecontextVars.ContextVar
to pass context data instead.Field
,Mapping
, andNumber
should no longer be used as fields within schemas. Use their subclasses instead.
3.23.3 (2025-01-03)¶
Bug fixes:
Typing: Fix typing for
Schema.from_dict
(#1653). Thanks @SteadBytes for reporting.
Support:
Documentation: Various documentation cleanups, including more concise docs in the
marshmallow.fields
API reference (#2307). Thanks @AbdealiLoKo for reporting.
3.23.2 (2024-12-18)¶
Bug fixes:
Improve type hint formatting for
Field
,Nested
, andFunction
fields to resolve PyCharm warnings (#2268). Thanks @Fares-Abubaker for reporting and fixing.
3.23.1 (2024-11-01)¶
Support:
3.23.0 (2024-10-17)¶
Features:
Typing: replace “type” with specific metaclass for
Schema
andField
.
Other changes:
3.22.0 (2024-08-20)¶
Features:
Add
many
Meta option toSchema
so it expects a collection by default (#2270). Thanks @himalczyk for reporting and @deckar01 for the PR.
3.21.3 (2024-06-05)¶
Bug fixes:
3.21.2 (2024-05-01)¶
Bug fixes:
3.21.1 (2024-03-04)¶
Bug fixes:
3.21.0 (2024-02-26)¶
Bug fixes:
Fix validation of
URL
fields to allow missing user field, per NWG RFC 3986 (#2232). Thanks @ddennerline3 for reporting and @deckar01 for the PR.
Other changes:
Backwards-incompatible:
__version__
,__parsed_version__
, and__version_info__
attributes are deprecated (#2227). Use feature detection orimportlib.metadata.version("marshmallow")
instead.
3.20.2 (2024-01-09)¶
Bug fixes:
Fix
Nested
field type hint for lambdaSchema
types (#2164). Thanks @somethingnew2-0 for the PR.
Other changes:
3.20.1 (2023-07-20)¶
Bug fixes:
Fix call to
get_declared_fields
: passdict_cls
again (#2152). Thanks @Cheaterman for reporting.
3.20.0 (2023-07-20)¶
Features:
Add
absolute
parameter toURL
validator andUrl
field (#2123). Thanks @sirosen for the PR.Use Abstract Base Classes to define
FieldABC
andSchemaABC
(#1449). Thanks @aditkumar72 for the PR.Use
OrderedSet
as defaultset_class
. Schemas are now ordered by default. (#1744)
Bug fixes:
Handle
OSError
andOverflowError
inutils.from_timestamp
(#2102). Thanks @TheBigRoomXXL for the PR.Fix the default inheritance of nested partial schemas (#2149). Thanks @matejsp for reporting.
Other changes:
3.19.0 (2022-11-11)¶
Features:
3.18.0 (2022-09-15)¶
Features:
Bug fixes:
Fix typing in
Field._serialize
signature (#2046).
3.17.1 (2022-08-22)¶
Bug fixes:
3.17.0 (2022-06-26)¶
Features:
Support serialization as float in
TimeDelta
field (#1998). Thanks @marcosatti for the PR.Add
messages_dict
property toValidationError
to facilitate type checking (#1976). Thanks @sirosen for the PR.
3.16.0 (2022-05-29)¶
Features:
Raise
ValueError
if an invalid value is passed to theunknown
argument (#1721, #1732). Thanks @sirosen for the PR.
Other changes:
Set lower bound for
packaging
requirement (#1957). Thanks @MatthewNicolTR for reporting and thanks @sirosen for the PR.Improve warning messages by passing
stacklevel
(#1986). Thanks @tirkarthi for the PR.
3.15.0 (2022-03-12)¶
Features:
Other changes:
3.14.1 (2021-11-13)¶
Bug fixes:
3.14.0 (2021-10-17)¶
Bug fixes:
Fix
fields.TimeDelta
serialization precision (#1865). Thanks @yarsanich for reporting.
Other changes:
Fix type-hints for
data
arg inSchema.validate
to accept list of dictionaries (#1790, #1868). Thanks @yourun-proger for PR.Improve warning when passing metadata as keyword arguments (#1882). Thanks @traherom for the PR.
Don’t build universal wheels. We don’t support Python 2 anymore. (#1860) Thanks @YKdvd for reporting.
Make the build reproducible (#1862).
Drop support for Python 3.5 (#1863).
Test against Python 3.10 (#1888).
3.13.0 (2021-07-21)¶
Features:
Replace
missing
/default
field parameters withload_default
/dump_default
(#1742). Thanks @sirosen for the PR.
Deprecations:
The use of
missing
/default
field parameters is deprecated and will be removed in marshmallow 4.load_default
/dump_default
should be used instead.
3.12.2 (2021-07-06)¶
Bug fixes:
Don’t expose
Field
s asSchema
attributes. This reverts a change introduced in 3.12.0 that causes issues when field names conflict withSchema
attributes or methods.Fields
s are still accessible on aSchema
instance through thefields
attribute. (#1843)
3.12.1 (2021-05-10)¶
Bug fixes:
Fix bug that raised an
AttributeError
when instantiating aSchema
with a field namedparent
(#1808). Thanks @flying-sheep for reporting and helping with the fix.
3.12.0 (2021-05-09)¶
Features:
Add
validate.And
(#1768). Thanks @rugleb for the suggestion.Add type annotations to
marshmallow.decorators
(#1788, #1789). Thanks @michaeldimchuk for the PR.Let
Field
s be accessed by name asSchema
attributes (#1631).
Other changes:
3.11.1 (2021-03-29)¶
Bug fixes:
3.11.0 (2021-03-28)¶
Features:
Add
fields.IPInterface
,fields.IPv4Interface
, andIPv6Interface
(#1733). Thanks @madeinoz67 for the suggestion and the PR.Raise
AttributeError
for missing methods when usingfields.Method
(#1675). Thanks @lassandroan.
Other changes:
Remove unnecessary
hasattr
andgetattr
checks inField
(#1770).
3.10.0 (2020-12-19)¶
Deprecations:
3.9.1 (2020-11-07)¶
Bug fixes:
3.9.0 (2020-10-31)¶
Features:
Add
format
argument tofields.Time
andtimeformat
class Meta
option (#686). Thanks @BennyAlex for the suggestion and thanks @infinityxxx for the PR.
Other changes:
3.8.0 (2020-09-16)¶
Features:
Bug fixes:
Fix typing in
AwareDateTime
(#1658). Thanks @adithyabsk for reporting.
3.7.1 (2020-07-20)¶
Bug fixes:
3.7.0 (2020-07-08)¶
Deprecations:
marshmallow.pprint
is deprecated and will be removed in marshmallow 4 (#1588).
Support:
Bug fixes:
Fix passing
only
andexclude
toNested
with an orderedSchema
(#1627). Thanks @juannorris for the PR.
3.6.1 (2020-06-02)¶
No code changes–only docs and contributor-facing updates in this release.
Support:
Documentation: improve custom fields example (#1538). Thanks @pablospizzamiglio for reporting the problem with the old example and thanks @Resinderate for the PR.
Documentation: Split up API reference into multiple pages and add summary tables (#1587). Thanks @EpicWink for the PR.
3.6.0 (2020-05-08)¶
Features:
Add
validate.ContainsNoneOf
(#1528). Thanks @Resinderate for the suggestion and the PR.
3.5.2 (2020-04-30)¶
Bug fixes:
3.5.1 (2020-03-05)¶
Bug fixes:
Includes bug fix from 2.21.0.
3.5.0 (2020-02-19)¶
Bug fixes:
Fix list of nullable nested fields
List(Nested(Field, allow_none=True)
(#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.
3.4.0 (2020-02-02)¶
Features:
Bug fixes:
Fix typing for
data
param ofSchema.load
andValidationError
(#1492). Thanks @mehdigmira for reporting and thanks @dfirst for the PR.
Other changes:
3.3.0 (2019-12-05)¶
Features:
fields.Nested
may take a callable that returns a schema instance. Use this to resolve order-of-declaration issues when schemas nest each other (#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.Nested
is 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:
3.2.2 (2019-11-04)¶
Bug fixes:
Don’t load fields for which
load_only
anddump_only
are bothTrue
(#1448).Fix types in
marshmallow.validate
(#1446).
Support:
Test against Python 3.8 (#1431).
3.2.1 (2019-09-30)¶
Bug fixes:
Fix typing for
Schema.dump[s]
(#1416).
3.2.0 (2019-09-17)¶
Features:
Bug fixes:
Fix compatibility with Python < 3.5.3 (#1409). Thanks @lukaszdudek-silvair for reporting.
Refactoring:
Remove unnecessary
BaseSchema
superclass (#1406).
3.1.1 (2019-09-16)¶
Bug fixes:
Restore inheritance hierarchy of
Number
fields (#1403).fields.Integer
andfields.Decimal
inherit fromfields.Number
.Fix bug that raised an uncaught error when a nested schema instance had an unpickleable object in its context (#1404). Thanks @metheoryt for reporting.
3.1.0 (2019-09-15)¶
Features:
Add more type annotations (#663). Type information is distributed per PEP 561 . Thanks @fuhrysteve for helping with this.
Bug fixes:
Includes bug fix from 2.20.5.
3.0.5 (2019-09-12)¶
Bug fixes:
Fix bug that raised an uncaught error when passing both a schema instance and
only
toNested
(#1395). This bug also affected passing a schema instance tofields.Pluck
.
3.0.4 (2019-09-11)¶
Bug fixes:
3.0.3 (2019-09-04)¶
Bug fixes:
3.0.2 (2019-09-04)¶
Bug fixes:
3.0.1 (2019-08-21)¶
Bug fixes:
3.0.0 (2019-08-18)¶
Features:
Optimize
List(Nested(...))
(#779).Minor performance improvements and cleanup (#1328).
Add
Schema.from_dict
(#1312).
Deprecations/Removals:
Field.fail
is deprecated. UseField.make_error
instead.Remove UUID validation from
fields.UUID
, for consistency with other fields (#1132).
Support:
Various docs improvements (#1329).
3.0.0rc9 (2019-07-31)¶
Features:
Backwards-incompatible: Validation does not occur on serialization (#1132). This significantly improves serialization performance.
Backwards-incompatible:
DateTime
does not affect timezone information on serialization and deserialization (#1234, #1278).Add
NaiveDateTime
andAwareDateTime
to enforce timezone awareness (#1234, #1287).Backwards-incompatible:
List
does not wrap single values in a list on serialization (#1307).Backwards-incompatible:
Schema.handle_error
receivesmany
andpartial
as keyword arguments (#1321).Use
raise from
more uniformly to improve stack traces (#1313).Rename
Nested.__schema
toNested._schema
to prevent name mangling (#1289).Performance improvements (#1309).
Deprecations/Removals:
LocalDateTime
is removed (#1234).marshmallow.utils.utc
is removed. Usedatetime.timezone.utc
instead.
Bug fixes:
Fix behavior of
List(Nested("self"))
(#779 (comment)).
Support:
Document usage of
validate.Regexp
’s usagere.search
(#1285). Thanks @macdonaldezra.
3.0.0rc8 (2019-07-04)¶
Features:
Propagate
only
andexclude
parameters toNested
fields withinList
andDict
(#779, #946).Use
email.utils.parsedate_to_datetime
instead of conditionally using dateutil for parsing RFC dates (#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. (#1265)
Improve error messages for
validate.Range
.Use
raise from error
for better stack traces (#1254). Thanks @fuhrysteve.python-dateutil is no longer used. This resolves the inconsistent behavior based on the presence of python-dateutil (#497, #1234).
Bug fixes:
Fix method resolution for
__init__
method offields.Email
andfields.URL
(#1268). Thanks @dursk for the catch and patch.Includes bug fixes from 2.19.4 and 2.19.5.
Other changes:
Backwards-incompatible: Rename
fields.List.container
tofields.List.inner
,fields.Dict.key_container
tofields.Dict.key_field
, andfields.Dict.value_container
tofields.Dict.value_field
.Switch to Azure Pipelines for CI (#1261).
3.0.0rc7 (2019-06-15)¶
Features:
Backwards-incompatible:
many
is passed as a keyword argument to methods decorated withpre_load
,post_load
,pre_dump
,post_dump
, andvalidates_schema
.partial
is passed as a keyword argument to methods decorated withpre_load
,post_load
andvalidates_schema
.**kwargs
should be added to all decorated methods.Add
min_inclusive
andmax_exclusive
parameters tovalidate.Range
(#1221). Thanks @kdop for the PR.
Bug fixes:
Fix propagation of
partial
toNested
containers (part of #779).Includes bug fix from 2.19.3.
Other changes:
Backwards-incompatible: Use keyword-only arguments (#1216).
3.0.0rc6 (2019-05-05)¶
Support:
Backwards-incompatible: Remove support for Python 2 (#1120). Only Python>=3.5 is supported. Thank you @rooterkyberian for the suggestion and the PR.
Backwards-incompatible: Remove special-casing in
fields.List
andfields.Tuple
for accessing nested attributes (#1188). Usefields.List(fields.Pluck(...))
instead.Upgrade syntax with
pyupgrade
in pre-commit (#1195). Thanks again @hugovk.
3.0.0rc5 (2019-03-30)¶
Features:
Allow input value to be included in error messages for a number of fields (#1129). Thanks @hdoupe for the PR.
Improve default error messages for
OneOf
andContainsOnly
(#885). Thanks @mcgfeller for the suggestion and @maxalbert for the PR.
Deprecations/Removals:
Remove
fields.FormattedString
(#1141). Usefields.Function
orfields.Method
instead.
Bug fixes:
Includes bug fix from 2.19.2.
3.0.0rc4 (2019-02-08)¶
Features:
Add
fields.Mapping
, which makes it easier to support other mapping types (e.g.OrderedDict
) (#1092). Thank @sayanarijit for the suggestion and the PR.
3.0.0rc3 (2019-01-13)¶
Features:
Make the error messages for “unknown fields” and “invalid data type” configurable (#852). Thanks @Dunstrom for the PR.
fields.Boolean
parses"yes"
/"no"
values (#1081). Thanks @r1b.
Other changes:
Backwards-incompatible with previous 3.x versions: Change ordering of
keys
andvalues
arguments tofields.Dict
.Remove unused code in
marshmallow.utils
:is_indexable_but_not_string
,float_to_decimal
,decimal_to_fixed
,from_iso
(#1088).Remove unused
marshmallow.compat.string_types
.
Bug fixes:
Includes bug fix from 2.18.0.
3.0.0rc2 (2019-01-03)¶
Features:
Add
register
class Meta option to allow bypassing marshmallow’s internal class registry when memory usage is critical (#660).
Bug fixes:
Fix serializing dict-like objects with properties (#1060). Thanks @taion for the fix.
Fix populating
ValidationError.valid_data
forList
andDict
fields (#766).
Other changes:
Add
marshmallow.__version_info__
(#1074).Remove the
marshmallow.marshalling
internal module (#1070).A
ValueError
is raised when themissing
parameter is passed for required fields (#1040).Extra keyword arguments passed to
ValidationError
in validators are no longer passed to the finalValidationError
raised upon validation completion (#996).
3.0.0rc1 (2018-11-29)¶
Features:
Backwards-incompatible: Rework
ValidationError
API. It now expects a single field name, and error structures are merged in the finalValidationError
raised when validation completes. This allows schema-level validators to raise errors for individual fields (#441). Thanks @maximkulkin for writing the originalmerge_errors
implementation in #442 and thanks @lafrech for completing the implementation in #1026.
Bug fixes:
3.0.0b20 (2018-11-01)¶
Bug fixes:
Includes bug fixes from 2.16.2 and 2.16.3.
3.0.0b19 (2018-10-24)¶
Features:
Support partial loading of nested fields (#438). Thanks @arbor-dwatson for the PR. Note: Subclasses of
fields.Nested
now take an additionalpartial
parameter in the_deserialize
method.
Bug fixes:
Restore
Schema.TYPE_MAPPING
, which was removed in 3.0.0b17 (#1012).
Other changes:
Backwards-incompatible:
_serialize
and_deserialize
methods of allfields.Field
subclasses must accept**kwargs
(#1007).
3.0.0b18 (2018-10-15)¶
Bug fixes:
Deprecations/Removals:
prefix
parameter orSchema
class is removed (#991). The same can be achieved using a@post_dump
method.
3.0.0b17 (2018-10-13)¶
Features:
Add
format
option toDate
field (#869).Backwards-incompatible: Rename
DateTime
’sdateformat
Meta option todatetimeformat
.dateformat
now applies toDate
(#869). Thanks @knagra for implementing these changes.Enforce ISO 8601 when deserializing date and time (#899). Thanks @dushr for the report and the work on the PR.
Backwards-incompatible: Raise
ValueError
onSchema
instantiation in case ofattribute
ordata_key
collision (#992).
Bug fixes:
Fix inconsistencies in field inference by refactoring the inference feature into a dedicated field (#809). Thanks @taion for the PR.
When
unknown
is not passed toNested
, default to nestedSchema
unknown
meta option rather thanRAISE
(#963). Thanks @vgavro for the PR.Fix loading behavior of
fields.Pluck
(#990).Includes bug fix from 2.16.0.
3.0.0b16 (2018-09-20)¶
Bug fixes:
3.0.0b15 (2018-09-18)¶
Bug fixes:
Raise
ValidationError
instead ofTypeError
when non-iterable types are validated withmany=True
(#851).many=True
no longer iterates overstr
andcollections.abc.Mapping
objects and instead raises aValidationError
with{'_schema': ['Invalid input type.']}
(#930).Return
[]
asValidationError.valid_data
instead of{}
whenmany=True
(#907).
Thanks @tuukkamustonen for implementing these changes.
3.0.0b14 (2018-09-15)¶
Features:
Add
fields.Pluck
for serializing a single field from a nested object (#800). Thanks @timc13 for the feedback and @deckar01 for the implementation.Backwards-incompatible: Passing a string argument as
only
tofields.Nested
is no longer supported. Usefields.Pluck
instead (#800).Raise a
StringNotCollectionError
ifonly
orexclude
is passed as a string tofields.Nested
(#931).Backwards-incompatible:
Float
takes anallow_nan
parameter to explicitly allow serializing and deserializing special values (nan
,inf
and-inf
).allow_nan
defaults toFalse
.
Other changes:
Backwards-incompatible:
Nested
field now defaults tounknown=RAISE
instead ofEXCLUDE
. This harmonizes behavior withSchema
that already defaults toRAISE
(#908). Thanks @tuukkamustonen.Tested against Python 3.7.
3.0.0b13 (2018-08-04)¶
Bug fixes:
Errors reported by a schema-level validator for a field in a
Nested
field are stored under corresponding field name, not_schema
key (#862).Includes bug fix from 2.15.4.
Other changes:
Backwards-incompatible: The
unknown
option now defaults toRAISE
(#524 (comment), #851).Backwards-incompatible: When a schema error is raised with a
dict
as payload, thedict
overwrites any existing error list. Before this change, it would be appended to the list.Raise a
StringNotCollectionError
ifonly
orexclude
is passed as a string (#316). Thanks @paulocheque for reporting.
3.0.0b12 (2018-07-04)¶
Features:
The behavior to apply when encountering unknown fields while deserializing can be controlled with the
unknown
option (#524, #747, #127). It makes it possible to either “include”, “exclude”, or “raise”. Thanks @tuukkamustonen for the suggestion and thanks @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
None
does not imply data were mutated (#347). Thanks @tdevelioglu for reporting.Backwards-incompatible:
only
andexclude
are bound by declared and additional fields. AValueError
is raised if invalid fields are passed (#636). Thanks @jan-23 for reporting. Thanks @ikilledthecat and @deckar01 for the PRs.Format code using pre-commit (#855).
Deprecations/Removals:
ValidationError.fields
is removed (#840). Access field instances fromSchema.fields
.
3.0.0b11 (2018-05-20)¶
Features:
Minor performance improvement from simplifying
utils.get_value
(#811). Thanks again @taion.Add
require_tld
argument tofields.URL
(#749). Thanks @DenerKup for reporting and thanks @surik00 for the PR.fields.UUID
deserializesbytes
strings usingUUID(bytes=b'...')
(#625). Thanks @JeffBerger for the suggestion and the PR.
Bug fixes:
Fields nested within
Dict
correctly inherit context from their parent schema (#820). Thanks @RosanneZe for reporting and @deckar01 for the PR.Includes bug fix from 2.15.3.
3.0.0b10 (2018-05-10)¶
Bug fixes:
Includes bugfixes from 2.15.2.
3.0.0b9 (2018-04-25)¶
Features:
Backwards-incompatible:
missing
anddefault
values are passed in deserialized form (#378). Thanks @chadrik for the suggestion and thanks @lafrech for the PR.
Bug fixes:
Includes the bugfix from 2.15.1.
3.0.0b8 (2018-03-24)¶
Features:
Backwards-incompatible: Add
data_key
parameter to fields for specifying the key in the input and output data dict. This parameter replaces bothload_from
anddump_to
(#717). Thanks @lafrech.Backwards-incompatible: When
pass_original=True
is passed to one of the decorators and a collection is being (de)serialized, theoriginal_data
argument will be a single object unlesspass_many=True
is also passed to the decorator (#315, #743). Thanks @stj for the PR.Backwards-incompatible: Don’t recursively check nested required fields when the
Nested
field’s key is missing (#319). This reverts #235. Thanks @chekunkov reporting and thanks @lafrech for the PR.Backwards-incompatible: Change error message collection for
Dict
field (#730). Note: this is backwards-incompatible with previous 3.0.0bX versions. Thanks @shabble for the report and thanks @lafrech for the PR.
3.0.0b7 (2018-02-03)¶
Features:
Backwards-incompatible: Schemas are always strict (#377). The
strict
parameter is removed.Backwards-incompatible:
Schema().load
andSchema().dump
returndata
instead of a(data, errors)
tuple (#598).Backwards-incompatible:
Schema().load(None)
raises aValidationError
(#511).
See Upgrading to 3.0 for a guide on updating your code.
Thanks @lafrech for implementing these changes. Special thanks to @MichalKononenko, @douglas-treadwell, and @maximkulkin for the discussions on these changes.
Other changes:
Backwards-incompatible: Field name is not checked when
load_from
is specified (#714). Thanks @lafrech.
Support:
Add Code of Conduct.
3.0.0b6 (2018-01-02)¶
Bug fixes:
Fixes
ValidationError.valid_data
when a nested field contains errors (#710). This bug was introduced in 3.0.0b3. Thanks @lafrech.
Other changes:
3.0.0b5 (2017-12-30)¶
Features:
Add support for structured dictionaries by providing values and keys arguments to the
Dict
field’s constructor. This mirrors theList
field’s ability to validate its items (#483). Thanks @deckar01.
Other changes:
3.0.0b4 (2017-10-23)¶
Features:
Add support for millisecond, minute, hour, and week precisions to
fields.TimeDelta
(#537). Thanks @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 (#679). Thanks @bmwiedemann.Test against Python 3.6 in tox. Thanks @Fedalto.
Fix typo in exception message (#659). Thanks @wonderbeyond for reporting and thanks @yoichi for the PR.
3.0.0b3 (2017-08-20)¶
Features:
Add
valid_data
attribute toValidationError
.
Deprecations/Removals:
Deprecate
json_module
option in favor ofrender_module
(#364, #130). Thanks @justanr for the suggestion.
Bug fixes:
Includes bug fixes from releases 2.13.5 and 2.13.6.
Backwards-incompatible:
Number
fields don’t accept booleans as valid input (#623). Thanks @tuukkamustonen for the suggestion and thanks @rowillia for the PR.
Support:
Add benchmark script. Thanks @rowillia.
3.0.0b2 (2017-03-19)¶
Features:
Add
truthy
andfalsy
params tofields.Boolean
(#580). Thanks @zwack for the PR. Note: This is potentially a breaking change if your code passes thedefault
parameter positionally. Passdefault
as a keyword argument instead, e.g.fields.Boolean(default=True)
.
Other changes:
Backwards-incompatible:
validate.ContainsOnly
allows empty and duplicate values (#516, #603). Thanks @maximkulkin for the suggestion and thanks @lafrech for the PR.
Bug fixes:
Includes bug fixes from release 2.13.4.
3.0.0b1 (2017-03-10)¶
Features:
fields.Nested
respectsonly='field'
when deserializing (#307). Thanks @erlingbo for the suggestion and the PR.fields.Boolean
parses"on"
/"off"
(#580). Thanks @marcellarius for the suggestion.
Other changes:
Includes changes from release 2.13.2.
Backwards-incompatible:
skip_on_field_errors
defaults toTrue
forvalidates_schema
(#352).
3.0.0a1 (2017-02-26)¶
Features:
dump_only
andload_only
forFunction
andMethod
are set based onserialize
anddeserialize
arguments (#328).
Other changes:
Backwards-incompatible:
fields.Method
andfields.Function
no longer swallowAttributeErrors
(#395). Thanks @bereal for the suggestion.Backwards-incompatible:
validators.Length
is no longer a subclass ofvalidators.Range
(#458). Thanks @deckar01 for the catch and patch.Backwards-incompatible:
utils.get_func_args
no longer returns bound arguments. This is consistent with the behavior ofinspect.signature
. This change prevents a DeprecationWarning on Python 3.5 (#415, #479). Thanks @deckar01 for the PR.Backwards-incompatible: Change the signature of
utils.get_value
andSchema.get_attribute
for consistency with Python builtins (e.g.getattr
) (#341). Thanks @stas for reporting and thanks @deckar01 for the PR.Backwards-incompatible: Don’t unconditionally call callable attributes (#430, reverts #242). Thanks @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_error
andSchema.get_attribute
instead.Remove
func
parameter offields.Function
. Removemethod_name
parameter offields.Method
(issue:325
). Use theserialize
parameter instead.Remove
extra
parameter fromSchema
. Use a@post_dump
method to add additional data.
2.21.0 (2020-03-05)¶
Bug fixes:
Other changes:
Drop support for Python 3.4 (#1525).
2.20.5 (2019-09-15)¶
Bug fixes:
Fix behavior when a non-list collection is passed to the
validate
argument offields.Email
andfields.URL
(#1400).
2.20.4 (2019-09-11)¶
Bug fixes:
2.20.3 (2019-09-04)¶
Bug fixes:
Don’t swallow
TypeError
exceptions raised byField._bind_to_schema
orSchema.on_bind_field
(#1376).
2.20.2 (2019-08-20)¶
Bug fixes:
Prevent warning about importing from
collections
on Python 3.7 (#1354). Thanks @nicktimko for the PR.
2.20.1 (2019-08-13)¶
Bug fixes:
Fix bug that raised
TypeError
when invalid data type is passed to a nested schema with@validates
(#1342).
2.20.0 (2019-08-10)¶
Bug fixes:
Fix deprecated functions’ compatibility with Python 2 (#1337). Thanks @airstandley for the catch and patch.
Fix error message consistency for invalid input types on nested fields (#1303). This is a backport of the fix in #857. Thanks @cristi23 for the thorough bug report and the PR.
Deprecation/Removals:
Python 2.6 is no longer officially supported (#1274).
2.19.5 (2019-06-18)¶
Bug fixes:
Fix deserializing ISO8601-formatted datetimes with less than 6-digit miroseconds (#1251). Thanks @diego-plan9 for reporting.
2.19.4 (2019-06-16)¶
Bug fixes:
Microseconds no longer gets lost when deserializing datetimes without dateutil installed (#1147).
2.19.3 (2019-06-15)¶
Bug fixes:
2.19.2 (2019-03-30)¶
Bug fixes:
Handle
OverflowError
when (de)serializing large integers withfields.Float
(#1177). Thanks @brycedrennan for the PR.
2.19.1 (2019-03-16)¶
Bug fixes:
2.19.0 (2019-03-07)¶
Deprecation/Removal:
A
RemovedInMarshmallow3
warning is raised when usingfields.FormattedString
. Usefields.Method
orfields.Function
instead (#1141).
2.18.1 (2019-02-15)¶
Bug fixes:
2.18.0 (2019-01-13)¶
Features:
Add warnings for functions in
marshmallow.utils
that are removed in marshmallow 3.
Bug fixes:
Copying
missing
withcopy.copy
orcopy.deepcopy
will not duplicate it (#1099).
2.17.0 (2018-12-26)¶
Features:
2.16.3 (2018-11-01)¶
Bug fixes:
2.16.2 (2018-10-30)¶
Bug fixes:
2.16.1 (2018-10-17)¶
Bug fixes:
Remove spurious warning about implicit collection handling (#998). Thanks @lalvarezguillen for reporting.
2.16.0 (2018-10-10)¶
Bug fixes:
Allow username without password in basic auth part of the url in
fields.Url
(#982). Thanks user:alefnula
for the PR.
Other changes:
Drop support for Python 3.3 (#987).
2.15.6 (2018-09-20)¶
Bug fixes:
Prevent
TypeError
when a non-collection is passed to aSchema
withmany=True
. Instead, raiseValidationError
with{'_schema': ['Invalid input type.']}
(#906).Fix
root
attribute for nested container fields on list on inheriting schemas (#956). Thanks @bmcbu for reporting.
These fixes were backported from 3.0.0b15 and 3.0.0b16.
2.15.5 (2018-09-15)¶
Bug fixes:
Handle empty SQLAlchemy lazy lists gracefully when dumping (#948). Thanks @vke-code for the catch and @YuriHeupa for the patch.
2.15.4 (2018-08-04)¶
Bug fixes:
Respect
load_from
when reporting errors for@validates('field_name')
(#748). Thanks @m-novikov for the catch and patch.
2.15.3 (2018-05-20)¶
Bug fixes:
2.15.2 (2018-05-10)¶
Bug fixes:
Fix a race condition in validation when concurrent threads use the same
Schema
instance (#783). Thanks @yupeng0921 and @lafrech for the fix.Fix serialization behavior of
fields.List(fields.Integer(as_string=True))
(#788). Thanks @cactus for reporting and @lafrech for the fix.Fix behavior of
exclude
parameter when passed from parent to nested schemas (#728). Thanks @timc13 for reporting and @deckar01 for the fix.
2.15.1 (2018-04-25)¶
Bug fixes:
CVE CVE-2018-17175: Fix behavior when an empty list is passed as the
only
argument (#772). Thanks @deckar01 for reporting and thanks @lafrech for the fix.
2.15.0 (2017-12-02)¶
Bug fixes:
Handle
UnicodeDecodeError
when deserializingbytes
with aString
field (#650). Thanks @dan-blanchard for the suggestion and thanks @4lissonsilveira for the PR.
2.14.0 (2017-10-23)¶
Features:
2.13.6 (2017-08-16)¶
Bug fixes:
Fix serialization of types that implement
__getitem__
(#669). Thanks @MichalKononenko.
2.13.5 (2017-04-12)¶
Bug fixes:
2.13.4 (2017-03-19)¶
Bug fixes:
2.13.3 (2017-03-11)¶
Bug fixes:
2.13.2 (2017-03-10)¶
Bug fixes:
Support:
Update contributing docs.
2.13.1 (2017-03-04)¶
Bug fixes:
2.13.0 (2017-02-18)¶
Features:
2.12.2 (2017-01-30)¶
Bug fixes:
Unbound fields return
None
rather returning the field itself. This fixes a corner case introduced in #572. Thanks @touilleMan for reporting and @YuriHeupa for the fix.
2.12.1 (2017-01-23)¶
Bug fixes:
Fix behavior when a
Nested
field is composed within aList
field (#572). Thanks @avish for reporting and @YuriHeupa for the PR.
2.12.0 (2017-01-22)¶
Features:
Allow passing nested attributes (e.g.
'child.field'
) to thedump_only
andload_only
parameters ofSchema
(#572). Thanks @YuriHeupa for the PR.Add
schemes
parameter tofields.URL
(#574). Thanks @mosquito for the PR.
2.11.1 (2017-01-08)¶
Bug fixes:
Allow
strict
class Meta option to be overridden by constructor (#550). Thanks @douglas-treadwell for reporting and thanks @podhmo for the PR.
2.11.0 (2017-01-08)¶
Features:
Import
marshmallow.fields
inmarshmallow/__init__.py
to save an import when importing themarshmallow
module (#557). Thanks @mindojo-victor.
Support:
2.10.5 (2016-12-19)¶
Bug fixes:
Reset user-defined kwargs passed to
ValidationError
on eachSchema.load
call (#565). Thanks @jbasko for the catch and patch.
Support:
2.10.4 (2016-11-18)¶
Bug fixes:
Function
field works with callables that use Python 3 type annotations (#540). Thanks @martinstein for reporting and thanks @sabinem, @lafrech, and @maximkulkin for the work on the PR.
2.10.3 (2016-10-02)¶
Bug fixes:
Fix behavior for serializing missing data with
Number
fields whenas_string=True
is passed (#538). Thanks @jessemyers for reporting.
2.10.2 (2016-09-25)¶
Bug fixes:
2.10.1 (2016-09-14)¶
Bug fixes:
Fix behavior when using
validate.Equal(False)
(#484). Thanks @pktangyue for reporting and thanks @tuukkamustonen for the fix.Fix
strict
behavior when errors are raised inpre_dump
/post_dump
processors (#521). Thanks @tvuotila for the catch and patch.Fix validation of nested fields on dumping (#528). Thanks again @tvuotila.
2.10.0 (2016-09-05)¶
Features:
Errors raised by pre/post-load/dump methods will be added to a schema’s errors dictionary (#472). Thanks @dbertouille for the suggestion and for the PR.
2.9.1 (2016-07-21)¶
Bug fixes:
Fix serialization of
datetime.time
objects with microseconds (#464). Thanks @Tim-Erwin for reporting and thanks @vuonghv for the fix.Make
@validates
consistent with field validator behavior: if validation fails, the field will not be included in the deserialized output (#391). Thanks @martinstein for reporting and thanks @vuonghv for the fix.
2.9.0 (2016-07-06)¶
Decimal
field coerces input values to a string before deserializing to adecimal.Decimal
object in order to avoid transformation of float values under 12 significant digits (#434, #435). Thanks @davidthornton for the PR.
2.8.0 (2016-06-23)¶
Features:
Allow
only
andexclude
parameters to take nested fields, using dot-delimited syntax (e.g.only=['blog.author.email']
) (#402). Thanks @Tim-Erwin and @deckar01 for the discussion and implementation.
Support:
Update tasks.py for compatibility with invoke>=0.13.0. Thanks @deckar01.
2.7.3 (2016-05-05)¶
2.7.2 (2016-04-27)¶
No code changes in this release. This is a reupload in order to distribute an sdist for the last hotfix release. See #443.
Support:
Update license entry in setup.py to fix RPM distributions (#433). Thanks @rrajaravi for reporting.
2.7.1 (2016-04-08)¶
Bug fixes:
Only add Schemas to class registry if a class name is provided. This allows Schemas to be constructed dynamically using the
type
constructor without getting added to the class registry (which is useful for saving memory).
2.7.0 (2016-04-04)¶
Features:
Make context available to
Nested
field’son_bind_field
method (#408). Thanks @immerrr for the PR.Pass through user
ValidationError
kwargs (#418). Thanks @russelldavies for helping implement this.
Other changes:
Remove unused attributes
root
,parent
, andname
fromSchemaABC
(#410). Thanks @Tim-Erwin for the PR.
2.6.1 (2016-03-17)¶
Bug fixes:
2.6.0 (2016-02-01)¶
Features:
Add
partial
argument toSchema.validate
(#379). Thanks @tdevelioglu for the PR.Add
equal
argument tovalidate.Length
. Thanks @daniloakamine.Collect all validation errors for each item deserialized by a
List
field (#345). Thanks @maximkulkin for the report and the PR.
2.5.0 (2016-01-16)¶
Features:
Allow a tuple of field names to be passed as the
partial
argument toSchema.load
(#369). Thanks @tdevelioglu for the PR.Add
schemes
argument tovalidate.URL
(#356).
2.4.2 (2015-12-08)¶
Bug fixes:
Prevent duplicate error messages when validating nested collections (#360). Thanks @alexmorken for the catch and patch.
2.4.1 (2015-12-07)¶
Bug fixes:
Serializing an iterator will not drop the first item (#343, #353). Thanks @jmcarp for the patch. Thanks @edgarallang and @jmcarp for reporting.
2.4.0 (2015-12-06)¶
Features:
Add
skip_on_field_errors
parameter tovalidates_schema
(#323). Thanks @jjvattamattom for the suggestion and @d-sutherland for the PR.
Bug fixes:
2.3.0 (2015-11-22)¶
Features:
Add
dump_to
parameter to fields (#310). Thanks @ShayanArmanPercolate for the suggestion. Thanks @franciscod and @ewang for the PRs.The
deserialize
function passed tofields.Function
can optionally receive acontext
argument (#324). Thanks @DamianHeard.The
serialize
function passed tofields.Function
is optional (#325). Thanks again @DamianHeard.The
serialize
function passed tofields.Method
is optional (#329). Thanks @justanr.
Deprecation/Removal:
The
func
argument offields.Function
has been renamed toserialize
.The
method_name
argument offields.Method
has been renamed toserialize
.
func
and method_name
are still present for backwards-compatibility, but they will both be removed in marshmallow 3.0.
2.2.1 (2015-11-11)¶
Bug fixes:
Skip field validators for fields that aren’t included in
only
(#320). Thanks @carlos-alberto for reporting and @eprikazc for the PR.
2.2.0 (2015-10-26)¶
Features:
Add support for partial deserialization with the
partial
argument toSchema
andSchema.load
(#290). Thanks @taion.
Deprecation/Removals:
Query
andQuerySelect
fields are removed.Passing of strings to
required
andallow_none
is removed. Pass theerror_messages
argument instead.
Support:
Add example of Schema inheritance in docs (#225). Thanks @martinstein for the suggestion and @juanrossi for the PR.
Add “Customizing Error Messages” section to custom fields docs.
2.1.3 (2015-10-18)¶
Bug fixes:
2.1.2 (2015-10-14)¶
Bug fixes:
Fix passing data to schema validator when using
@validates_schema(many=True)
(#297). Thanks @d-sutherland for reporting.Fix usage of
@validates
with a nested field whenmany=True
(#298). Thanks @nelfin for the catch and patch.
2.1.1 (2015-10-07)¶
Bug fixes:
Constant
field deserializes to its value regardless of whether its field name is present in input data (#291). Thanks @fayazkhan for reporting.
2.1.0 (2015-09-30)¶
Features:
Add
Dict
field for arbitrary mapping data (#251). Thanks @dwieeb for adding this and @Dowwie for the suggestion.Add
Field.root
property, which references the field’s Schema.
Deprecation/Removals:
The
extra
param ofSchema
is deprecated. Add extra data in apost_load
method instead.UnmarshallingError
andMarshallingError
are removed.
Bug fixes:
Fix storing multiple schema-level validation errors (#287). Thanks @evgeny-sureev for the patch.
If
missing=None
on a field,allow_none
will be set toTrue
.
Other changes:
A
List's
inner field will have the list field set as its parent. Useroot
to access theSchema
.
2.0.0 (2015-09-25)¶
Features:
Make error messages configurable at the class level and instance level (
Field.default_error_messages
attribute anderror_messages
parameter, respectively).
Deprecation/Removals:
Remove
make_object
. Use apost_load
method instead (#277).Remove the
error
parameter and attribute ofField
.Passing string arguments to
required
andallow_none
is deprecated. Pass theerror_messages
argument instead. This API will be removed in version 2.2.Remove
Arbitrary
,Fixed
, andPrice
fields (#86). UseDecimal
instead.Remove
Select
/Enum
fields (#135). Use theOneOf
validator instead.
Bug fixes:
Fix error format for
Nested
fields whenmany=True
. Thanks @alexmorken.pre_dump
methods are invoked before implicit field creation. Thanks @makmanalp for reporting.Return correct “required” error message for
Nested
field.The
only
argument passed to aSchema
is bounded by thefields
option (#183). Thanks @lustdante for the suggestion.
Changes from 2.0.0rc2:
error_handler
andaccessor
options are replaced with thehandle_error
andget_attribute
methods #284.Remove
marshmallow.compat.plain_function
since it is no longer used.Non-collection values are invalid input for
List
field (#231). Thanks @density for reporting.Bug fix: Prevent infinite loop when validating a required, self-nested field. Thanks @Bachmann1234 for the fix.
2.0.0rc2 (2015-09-16)¶
Deprecation/Removals:
make_object
is deprecated. Use apost_load
method instead (#277). This method will be removed in the final 2.0 release.Schema.accessor
andSchema.error_handler
decorators are deprecated. Define theaccessor
anderror_handler
class Meta options instead.
Bug fixes:
Allow non-field names to be passed to
ValidationError
(#273). Thanks @evgeny-sureev for the catch and patch.
Changes from 2.0.0rc1:
The
raw
parameter of thepre_*
,post_*
,validates_schema
decorators was renamed topass_many
(#276).Add
pass_original
parameter topost_load
andpost_dump
(#216).Methods decorated with the
pre_*
,post_*
, andvalidates_*
decorators must be instance methods. Class methods and instance methods are not supported at this time.
2.0.0rc1 (2015-09-13)¶
Features:
Backwards-incompatible:
fields.Field._deserialize
now takesattr
anddata
as arguments (#172). Thanks @alexmic and @kevinastone for the suggestion.Allow a
Field's
attribute
to be modified during deserialization (#266). Thanks @floqqi.Allow partially-valid data to be returned for
Nested
fields (#269). Thanks @jomag for the suggestion.Add
Schema.on_bind_field
hook which allows aSchema
to modify its fields when they are bound.Stricter validation of string, boolean, and number fields (#231). Thanks @touilleMan for the suggestion.
Improve consistency of error messages.
Deprecation/Removals:
Schema.validator
,Schema.preprocessor
, andSchema.data_handler
are removed. Usevalidates_schema
,pre_load
, andpost_dump
instead.QuerySelect
andQuerySelectList
are deprecated (#227). These fields will be removed in version 2.1.utils.get_callable_name
is removed.
Bug fixes:
If a date format string is passed to a
DateTime
field, it is always used for deserialization (#248). Thanks @bartaelterman and @praveen-p.
Support:
2.0.0b5 (2015-08-23)¶
Features:
If a field corresponds to a callable attribute, it will be called upon serialization. Thanks @alexmorken.
Add
load_only
anddump_only
class Meta
options. Thanks @kelvinhammond.If a
Nested
field is required, recursively validate any required fields in the nested schema (#235). Thanks @max-orhai.Improve error message if a list of dicts is not passed to a
Nested
field for whichmany=True
. Thanks again @max-orhai.
Bug fixes:
make_object
is only called after all validators and postprocessors have finished (#253). Thanks @sunsongxp for reporting.If an invalid type is passed to
Schema
andstrict=False
, store a_schema
error in the errors dict rather than raise an exception (#261). Thanks @density for reporting.
Other changes:
make_object
is only called when input data are completely valid (#243). Thanks @kissgyorgy for reporting.Change default error messages for
URL
andEmail
validators so that they don’t include user input (#255).Email
validator permits email addresses with non-ASCII characters, as per RFC 6530 (#221). Thanks @lextoumbourou for reporting and @mwstobo for sending the patch.
2.0.0b4 (2015-07-07)¶
Features:
List
field respects theattribute
argument of the inner field. Thanks @jmcarp.The
container
fieldList
field has access to its parentSchema
via itsparent
attribute. Thanks again @jmcarp.
Deprecation/Removals:
Legacy validator functions have been removed (#73). Use the class-based validators in
marshmallow.validate
instead.
Bug fixes:
Changes from 2.0.0b3:
If
load_from
is used on deserialization, the value ofload_from
is used as the key in the errors dict (#232). Thanks @alexmorken.
2.0.0b3 (2015-06-14)¶
Features:
Add
marshmallow.validates_schema
decorator for defining schema-level validators (#116).Add
marshmallow.validates
decorator for defining field validators as Schema methods (#116). Thanks @philtay.Performance improvements.
Defining
__marshallable__
on complex objects is no longer necessary.Add
fields.Constant
. Thanks @kevinastone.
Deprecation/Removals:
Remove
skip_missing
class Meta option. By default, missing inputs are excluded from serialized output (#211).Remove optional
context
parameter that gets passed to methods forMethod
fields.Schema.validator
is deprecated. Usemarshmallow.validates_schema
instead.utils.get_func_name
is removed. Useutils.get_callable_name
instead.
Bug fixes:
Fix serializing values from keyed tuple types (regression of #28). Thanks @makmanalp for reporting.
Other changes:
Remove unnecessary call to
utils.get_value
forFunction
andMethod
fields (#208). Thanks @jmcarp.Serializing a collection without passing
many=True
will not result in an error. Be very careful to pass themany
argument when necessary.
Support:
Documentation: Update Flask and Peewee examples. Update Quickstart.
Changes from 2.0.0b2:
Boolean
field serializesNone
toNone
, for consistency with other fields (#213). Thanks @cmanallen for reporting.Bug fix:
load_only
fields 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.
2.0.0b2 (2015-05-03)¶
Features:
Add useful
__repr__
methods to validators (#204). Thanks @philtay.Backwards-incompatible: By default,
NaN
,Infinity
, and-Infinity
are invalid values forfields.Decimal
. Passallow_nan=True
to allow these values. Thanks @philtay.
Changes from 2.0.0b1:
Fix serialization of
None
forTime
,TimeDelta
, andDate
fields (a regression introduced in 2.0.0a1).
Includes bug fixes from 1.2.6.
2.0.0b1 (2015-04-26)¶
Features:
Errored fields will not appear in (de)serialized output dictionaries (#153, #202).
Instantiate
OPTIONS_CLASS
inSchemaMeta
. This makesSchema.opts
available in metaclass methods. It also causes validation to occur earlier (uponSchema
class declaration rather than instantiation).Add
SchemaMeta.get_declared_fields
class method to support adding additional declared fields.
Deprecation/Removals:
Remove
allow_null
parameter offields.Nested
(#203).
Changes from 2.0.0a1:
Fix serialization of
None
forfields.Email
.
2.0.0a1 (2015-04-25)¶
Features:
Backwards-incompatible: When
many=True
, the errors dictionary returned bydump
andload
will be keyed on the indices of invalid items in the (de)serialized collection (#75). Addindex_errors=False
on a Schema’sclass Meta
options to disable this behavior.Backwards-incompatible: By default, fields will raise a ValidationError if the input is
None
. Theallow_none
parameter can override this behavior.Backwards-incompatible: A
Field's
default
parameter is only used if explicitly set and the field’s value is missing in the input toSchema.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.Str
no longer defaults to''
,fields.Int
no longer defaults to0
, etc. (#199). Thanks @jmcarp for the feedback.In
strict
mode, aValidationError
is raised. Error messages are accessed via theValidationError's
messages
attribute (#128).Add
allow_none
parameter tofields.Field
. IfFalse
(the default), validation fails when the field’s value isNone
(#76, #111). Ifallow_none
isTrue
,None
is considered valid and will deserialize toNone
.Schema-level validators can store error messages for multiple fields (#118). Thanks @ksesong for the suggestion.
Add
pre_load
,post_load
,pre_dump
, andpost_dump
Schema method decorators for defining pre- and post- processing routines (#153, #179). Thanks @davidism, @taion, and @jmcarp for the suggestions and feedback. Thanks @taion for the implementation.Error message for
required
validation is configurable. (#78). Thanks @svenstaro for the suggestion. Thanks @0xDCA for the implementation.Add
load_only
anddump_only
parameters to fields (#61, #87). Thanks @philtay.Schema validators can take an optional
raw_data
argument which contains raw input data, incl. data not specified in the schema (#127). Thanks @ryanlowe0.Add
validate.OneOf
(#135) andvalidate.ContainsOnly
(#149) validators. Thanks @philtay.Error messages for validators can be interpolated with
{input}
and other values (depending on the validator).fields.TimeDelta
always serializes to an integer value in order to avoid rounding errors (#105). Thanks @philtay.Add
include
class Meta option to support field names which are Python keywords (#139). Thanks @nickretallack for the suggestion.exclude
parameter is respected when used together withonly
parameter (#165). Thanks @lustdante for the catch and patch.fields.List
works as expected with generators and sets (#185). Thanks @sergey-aganezov-jr.
Deprecation/Removals:
MarshallingError
andUnmarshallingError
error are deprecated in favor of a singleValidationError
(#160).context
argument passed to Method fields is deprecated. Useself.context
instead (#184).Remove
ForcedError
.Remove support for generator functions that yield validators (#74). Plain generators of validators are still supported.
The
Select/Enum
field is deprecated in favor of usingvalidate.OneOf
validator (#135).Remove legacy, pre-1.0 API (
Schema.data
andSchema.errors
properties) (#73).Remove
null
value.
Other changes:
Marshaller
,Unmarshaller
were moved tomarshmallow.marshalling
. These should be considered private API (#129).Make
allow_null=True
the default forNested
fields. This will makeNone
serialize toNone
rather than a dictionary with empty values (#132). Thanks @nickrellack for the suggestion.
1.2.6 (2015-05-03)¶
Bug fixes:
Fix validation error message for
fields.Decimal
.Allow error message for
fields.Boolean
to be customized with theerror
parameter (like other fields).
1.2.5 (2015-04-25)¶
Bug fixes:
Fix validation of invalid types passed to a
Nested
field whenmany=True
(#188). Thanks @juanrossi for reporting.
Support:
Fix pep8 dev dependency for flake8. Thanks @taion.
1.2.4 (2015-03-22)¶
Bug fixes:
Other changes:
Remove dead code from
fields.Field
. Thanks @taion.
Support:
Correction to
_postprocess
method in docs. Thanks again @taion.
1.2.3 (2015-03-15)¶
Bug fixes:
Fix inheritance of
ordered
class Meta option (#162). Thanks @stephenfin for reporting.
1.2.2 (2015-02-23)¶
Bug fixes:
1.2.1 (2015-01-11)¶
Bug fixes:
A
Schema's
error_handler
–if defined–will execute ifSchema.validate
returns validation errors (#121).Deserializing
None
returnsNone
rather than raising anAttributeError
(#123). Thanks @RealSalmon for the catch and patch.
1.2.0 (2014-12-22)¶
Features:
Add
QuerySelect
andQuerySelectList
fields (#84).Convert validators in
marshmallow.validate
into class-based callables to make them easier to use when declaring fields (#85).Add
Decimal
field which is safe to use when dealing with precise numbers (#86).
Thanks @philtay for these contributions.
Bug fixes:
Date
fields correctly deserializes to adatetime.date
object whenpython-dateutil
is not installed (#79). Thanks @malexer for the catch and patch.Fix bug that raised an
AttributeError
when using a class-based validator.Fix
as_string
behavior of Number fields when serializing to default value.Deserializing
None
or the empty string with either aDateTime
,Date
,Time
orTimeDelta
results in the correct unmarshalling errors (#96). Thanks @svenstaro for reporting and helping with this.Fix error handling when deserializing invalid UUIDs (#106). Thanks @vesauimonen for the catch and patch.
Schema.loads
correctly defaults to use the value ofself.many
rather than defaulting toFalse
(#108). Thanks @davidism for the catch and patch.Validators, data handlers, and preprocessors are no longer shared between schema subclasses (#88). Thanks @amikholap for reporting.
Fix error handling when passing a
dict
orlist
to aValidationError
(#110). Thanks @ksesong for reporting.
Deprecation:
The validator functions in the
validate
module are deprecated in favor of the class-based validators (#85).The
Arbitrary
,Price
, andFixed
fields are deprecated in favor of theDecimal
field (#86).
Support:
Update docs theme.
Update contributing docs (#77).
Fix namespacing example in “Extending Schema” docs. Thanks @Ch00k.
Exclude virtualenv directories from syntax checking (#99). Thanks @svenstaro.
1.1.0 (2014-12-02)¶
Features:
Add
Schema.validate
method which validates input data against a schema. Similar toSchema.load
, but does not callmake_object
and only returns the errors dictionary.Add several validation functions to the
validate
module. Thanks @philtay.Store field name and instance on exceptions raised in
strict
mode.
Bug fixes:
Fix serializing dictionaries when field names are methods of
dict
(e.g."items"
). Thanks @rozenm for reporting.If a Nested field is passed
many=True
,None
serializes to an empty list. Thanks @nickretallack for reporting.Fix behavior of
many
argument passed todump
andload
. Thanks @svenstaro for reporting and helping with this.Fix
skip_missing
behavior forString
andList
fields. Thanks @malexer for reporting.Fix compatibility with python-dateutil 2.3.
More consistent error messages across
DateTime
,TimeDelta
,Date
, andTime
fields.
Support:
Update Flask and Peewee examples.
1.0.1 (2014-11-18)¶
Hotfix release.
Ensure that errors dictionary is correctly cleared on each call to
Schema.dump
andSchema.load
.
1.0.0 (2014-11-16)¶
Adds new features, speed improvements, better error handling, and updated documentation.
Add
skip_missing
class Meta
option.A field’s
default
may be a callable.Allow accessor function to be configured via the
Schema.accessor
decorator or the__accessor__
class member.URL
andEmail
fields are validated upon serialization.dump
andload
can receive themany
argument.Move a number of utility functions from fields.py to utils.py.
More useful
repr
forField
classes.If a field’s default is
fields.missing
and 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
OrderedDict
by default. If you want ordered field output, you must explicitly set theordered
option toTrue
.Backwards-incompatible:
error
parameter of theField
constructor is deprecated. Raise aValidationError
instead.Expanded test coverage.
Updated docs.
1.0.0-a (2014-10-19)¶
Major reworking and simplification of the public API, centered around support for deserialization, improved validation, and a less stateful Schema
class.
Rename
Serializer
toSchema
.Support for deserialization.
Use the
Schema.dump
andSchema.load
methods for serializing and deserializing, respectively.Backwards-incompatible: Remove
Serializer.json
andSerializer.to_json
. UseSchema.dumps
instead.Reworked fields interface.
Backwards-incompatible:
Field
classes implement_serialize
and_deserialize
methods.serialize
anddeserialize
comprise the public API for aField
.Field.format
andField.output
have been removed.Add
exceptions.ForcedError
which allows errors to be raised during serialization (instead of storing errors in theerrors
dict).Backwards-incompatible:
DateTime
field serializes to ISO8601 format by default (instead of RFC822).Backwards-incompatible: Remove
Serializer.factory
method. It is no longer necessary with thedump
method.Backwards-incompatible: Allow nesting a serializer within itself recursively. Use
exclude
oronly
to prevent infinite recursion.Backwards-incompatible: Multiple errors can be stored for a single field. The errors dictionary returned by
load
anddump
have lists of error messages keyed by field name.Remove
validated
decorator. Validation occurs withinField
methods.Function
field raises aValueError
if an uncallable object is passed to its constructor.Nested
fields inherit context from their parent.Add
Schema.preprocessor
andSchema.validator
decorators for registering preprocessing and schema-level validation functions respectively.Custom error messages can be specified by raising a
ValidationError
within a validation function.Extra keyword arguments passed to a Field are stored as metadata.
Fix ordering of field output.
Fix behavior of the
required
parameter onNested
fields.Fix serializing keyed tuple types (e.g.
namedtuple
) withclass Meta
options.Fix default value for
Fixed
andPrice
fields.Fix serialization of binary strings.
Schemas
can inherit fields from non-Schema
base classes (e.g. mixins). Also, fields are inherited according to the MRO (rather than recursing over base classes). Thanks @jmcarp.Add
Str
,Bool
, andInt
field class aliases.
0.7.0 (2014-06-22)¶
Add
Serializer.error_handler
decorator that registers a custom error handler.Add
Serializer.data_handler
decorator that registers data post-processing callbacks.Backwards-incompatible:
process_data
method is deprecated. Use thedata_handler
decorator instead.Fix bug that raised error when passing
extra
data together withmany=True
. Thanks @buttsicles for reporting.If
required=True
validation is violated for a givenField
, it will raise an error message that is different from the message specified by theerror
argument. Thanks @asteinlein.More generic error message raised when required field is missing.
validated
decorator should only wrap aField
class’soutput
method.
0.6.0 (2014-06-03)¶
Fix bug in serializing keyed tuple types, e.g.
namedtuple
andKeyedTuple
.Nested field can load a serializer by its class name as a string. This makes it easier to implement 2-way nesting.
Make
Serializer.data
override-able.
0.5.5 (2014-05-02)¶
Add
Serializer.factory
for creating a factory function that returns a Serializer instance.MarshallingError
stores its underlying exception as an instance variable. This is useful for inspecting errors.fields.Select
is aliased tofields.Enum
.Add
fields.__all__
andmarshmallow.__all__
so that the modules can be more easily extended.Expose
Serializer.OPTIONS_CLASS
as a class variable so that options defaults can be overridden.Add
Serializer.process_data
hook that allows subclasses to manipulate the final output data.
0.5.4 (2014-04-17)¶
Add
json_module
class Meta option.Add
required
option to fields . Thanks @DeaconDesperado.Tested on Python 3.4 and PyPy.
0.5.3 (2014-03-02)¶
Fix
Integer
field default. It is now0
instead of0.0
. Thanks @kalasjocke.Add
context
param toSerializer
. Allows accessing arbitrary objects inFunction
andMethod
fields.Function
andMethod
fields raiseMarshallingError
if their argument is uncallable.
0.5.2 (2014-02-10)¶
Enable custom field validation via the
validate
parameter.Add
utils.from_rfc
for parsing RFC datestring to Python datetime object.
0.5.1 (2014-02-02)¶
Avoid unnecessary attribute access in
utils.to_marshallable_type
for improved performance.Fix RFC822 formatting for localized datetimes.
0.5.0 (2013-12-29)¶
Can customize validation error messages by passing the
error
parameter to a field.Backwards-incompatible: Rename
fields.NumberField
->fields.Number
.Add
fields.Select
. Thanks @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=True
if serializing to a list. This ensures that marshmallow handles singular objects correctly, even if they are iterable.If Nested field
only
parameter 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.
0.4.1 (2013-12-01)¶
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.
0.4.0 (2013-11-24)¶
Add
additional
class Meta
option.Add
dateformat
class Meta
option.Support for serializing UUID, date, time, and timedelta objects.
Remove
Serializer.to_data
method. Just useSerialize.data
property.String field defaults to empty string instead of
None
.Backwards-incompatible:
isoformat
andrfcformat
functions moved to utils.py.Backwards-incompatible: Validation functions moved to validate.py.
Backwards-incompatible: Remove types.py.
Reorder parameters to
DateTime
field (first parameter is dateformat).Ensure that
to_json
returns bytestrings.Fix bug with including an object property in
fields
Meta option.Fix bug with passing
None
to a serializer.
0.3.1 (2013-11-16)¶
Fix bug with serializing dictionaries.
Fix error raised when serializing empty list.
Add
only
andexclude
parameters to Serializer constructor.Add
strict
parameter and option: causes Serializer to raise an error if invalid data are passed in, rather than storing errors.Updated Flask + SQLA example in docs.
0.3.0 (2013-11-14)¶
Declaring Serializers just got easier. The
class Meta
paradigm allows you to specify fields more concisely. Can specifyfields
andexclude
options.Allow date formats to be changed by passing
format
parameter toDateTime
field 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
.
0.2.1 (2013-11-12)¶
Allow prefixing field names.
Fix storing errors on Nested Serializers.
Python 2.6 support.
0.2.0 (2013-11-11)¶
Field-level validation.
Add
fields.Method
.Add
fields.Function
.Allow binding of extra data to a serialized object by passing the
extra
param when initializing aSerializer
.Add
relative
parameter tofields.Url
that allows for relative URLs.
0.1.0 (2013-11-10)¶
First release.