Skip to main content

Extended Marshmallow library

Project description

Marshmallow advanced Python library

Extra fields

Active field

Converts active field to state and back.

>>> from marshmallow_extended import Schema
>>> from marshmallow_extended.fields import Active

>>> class SimpleSchema(Schema):
        active = Active()

>>> SimpleSchema().dump({'state': 'active'})
{'active': True})
>>> SimpleSchema().dump({'state': 'inactive'})
{'active': False}

>>> SimpleSchema().load({'active': True})
{'state': 'active'}
>>> SimpleSchema().load({'active': False})
{'state': 'inactive'}

Filter by query parameter:

>>> class SimpleFilterSchema(Schema):
        active = Active(as_filter=True)

>>> SimpleFilterSchema().load({'active': 'true'})
{'state': 'active'}
>>> SimpleFilterSchema().load({'active': 'false'})
{'state': 'inactive'}
>>> SimpleFilterSchema().load({})
{'state__ne': 'deleted'}

For experienced usage try positives, negatives, positive_filter, negative_filter, missing_filter parameters. You can see behaviour for this parameters in tests.

Email field

Extended marshmallow.field.Email field: lowering case.

>>> from marshmallow_extended import Schema
>>> from marshmallow_extended.fields import Email

>>> class SimpleSchema(Schema):
        email = Email()

SimpleSchema().load({'email': 'Test@email.com'})
{'email': 'test@email.com'}

Changelog

1.3.1 (2021-06-10)

  • Added Enum and IContains fields.
  • Added get_params and apply_endpoint_params decorators.

1.3.0 (2021-06-10)

  • Added Email field.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marshmallow_extended-1.3.3.tar.gz (10.5 kB view details)

Uploaded Source

File details

Details for the file marshmallow_extended-1.3.3.tar.gz.

File metadata

  • Download URL: marshmallow_extended-1.3.3.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.8.1 requests/2.26.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for marshmallow_extended-1.3.3.tar.gz
Algorithm Hash digest
SHA256 f790fd4dec9506358284a2537cfa0bdb51d2bfbce4b0cfc807f4f75e881ee133
MD5 ca341d7e606e1bb70f6de6ef31836c64
BLAKE2b-256 dc12227e6f12a9e7e1ac93e83f4ea117f7de29f3401e7a806debf8f8a3f2d9f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page