Metadata-Version: 2.0
Name: marshmallow-models
Version: 0.1.0
Summary: Object models with validation and serialization using Marshmallow fields and validators.
Home-page: https://github.com/douglas-treadwell/marshmallow-models
Author: Douglas Treadwell
Author-email: douglas.treadwell@gmail.com
License: MIT
Keywords: serialization,rest,json,api,marshal,marshalling,deserialization,validation,schema,model,models,modelling,object,objects
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Dist: marshmallow

Marshmallow Models
==================


Inspired by [Schematics](https://github.com/schematics/schematics).

Whereas Marshmallow is an excellent serialization/deserialization
and validation library, it wasn't intended to be a class or type
definition library, which Schematics was.

This library provides a Schematics-like Model but
using Marshmallow's Fields and validation.


Usage
-----

Models are defined like Schemas, but whereas a Schema is instantiated
with parameters and then used to schema.dump(data) or schema.load(data),
or schema.validate(data),
Models are instantiated, attributes may be assigned to them, and then
they can be .dump()'d, .dumps()'d or .validate()'d.

```python
from marshmallow_models import Model
from marshmallow.fields import String, Integer

class PersonModel(Model):
    name = String(required=True, default='Anonymous')
    age = Integer(required=True)

person = PersonModel()

person.name = 'Tester'
person.age = 100

# or equivalently:
person = PersonModel({'name': 'Tester', 'age': 100})

# or equivalently:
person = PersonModel(name='Tester', age=100)

# throws marshmallow.exceptions.ValidationError if invalid
person.validate()

person.dump().data  # {'name': 'Tester', 'age': 100}
```

Configuration
-------------

Marshmallow Models support the "class Meta" configuration method,
and also support defining the "class Meta" using the alias
"class Options".


