marshmallow-validators

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


Keywords
validators, marshmallow, colander, deserialization, serialization, validation, wtforms
License
MIT
Install
pip install marshmallow-validators==1.0.0

Documentation

marshmallow-validators

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/ .

Project Links

License

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