Skip to main content

Use 3rd-party validators (e.g. from WTForms and colander) with marshmallow

Project description

Latest version Travis-CI marshmallow 3 compatible

Homepage: https://marshmallow-validators.readthedocs.io/

Use 3rd-party validators (e.g. from WTForms and colander) with marshmallow.

from marshmallow import Schema, fields
from marshmallow_validators.wtforms import from_wtforms
from wtforms.validators import Email, Length

# Leverage WTForms il8n
locales = ['de_DE', 'de']

class UserSchema(Schema):
    email = fields.Str(
        validate=from_wtforms([Email()], locales=locales)
    )
    password = fields.Str(
        validate=from_wtforms([Length(min=8, max=300)], locales=locales)
    )

UserSchema().validate({'email': 'invalid', 'password': 'abc'})
# {'email': ['Ungültige Email-Adresse.'],
# 'password': ['Feld muss zwischen 8 und 300 Zeichen beinhalten.']}

Get It Now

$ pip install -U marshmallow-validators

Documentation

Full documentation is available at https://marshmallow-validators.readthedocs.io/ .

License

MIT licensed. See the bundled LICENSE file for more details.

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-validators-3.0.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

marshmallow_validators-3.0.0-py2.py3-none-any.whl (4.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file marshmallow-validators-3.0.0.tar.gz.

File metadata

File hashes

Hashes for marshmallow-validators-3.0.0.tar.gz
Algorithm Hash digest
SHA256 93c2a1a76db7f5b76512e86494df9acea876b938c28d42d0428ebe914741493c
MD5 afd1634cc7847c63706b203facd1f5bf
BLAKE2b-256 ee5ba1bd96990cdaa5994202abd99d116e56dd4de7cc83d5d52b6ba367fe6b8b

See more details on using hashes here.

File details

Details for the file marshmallow_validators-3.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for marshmallow_validators-3.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 38bc71a4522cbb5c5467fde2ff165c9f1f62a123dea5e5b1be5aa2d44f23f116
MD5 30932b4d2cf3d103034a18f1bd1ecd46
BLAKE2b-256 9226bf3e04af8ffdf47cebd769e7082ded35dcdcb6969bbbb02660b6854e045a

See more details on using hashes here.

Supported by

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