Skip to content

onyg/aserializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aserializer

https://travis-ci.org/onyg/aserializer.png?branch=master pypi

About

aserializer is an object serializer inspired by the django forms.

Examples

Examples how code looks like:

class Address(Serializer):
    id = IntegerField(required=True, identity=True)
    street = StringField(required=True)
    streetNumber = StringField(required=True)
    city = StringField(required=False)
    country = StringField(required=False)

class User(Serializer):
    _type = TypeField('user')
    id = IntegerField(required=True, identity=True)
    name = StringField(required=True)
    email = EmailField(required=True)
    tel = StringField(required=False, min_length=10, max_length=50)
    address = SerializerField(Address, required=True)

Result:

user = User(DATA)
user.dump()

{
  "_type": "user",
  "id": 1,
  "name": "Joe",
  "email": "[email protected]",
  "tel": "+49 555 555 12",
  "address": {
    "id": 1,
    "street": "Street",
    "streetNumber": "5a",
    "city": "Berlin",
    "country": "Germany"
  }
}

Tests

To run the tests use the command: python setup.py nosetests

Contributing

Please find bugs and send pull requests to the GitHub repository and issue tracker.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages