• Stars
    star
    177
  • Rank 214,717 (Top 5 %)
  • Language
    Python
  • License
    Other
  • Created almost 12 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Data modeling and validation Python library

Booby: data modeling and validation

Latest version Docs License Number of PyPI downloads Build status

Booby is a standalone data modeling and validation library written in Python. Booby is under active development (visit this blog post for more info and the roadmap) and licensed under the Apache2 license, so feel free to contribute and report errors and suggestions.

Usage

See the sample code below to get an idea of the main features.

from booby import Model, fields


class Token(Model):
    key = fields.String()
    secret = fields.String()


class Address(Model):
    line_1 = fields.String()
    line_2 = fields.String()


class User(Model):
    login = fields.String(required=True)
    name = fields.String()
    email = fields.Email()
    token = fields.Embedded(Token, required=True)
    addresses = fields.Collection(Address)

jack = User(
    login='jack',
    name='Jack',
    email='[email protected]',
    token={
        'key': 'vs7dfxxx',
        'secret': 'ds5ds4xxx'
    },
    addresses=[
        {'line_1': 'Main Street'},
        {'line_1': 'Main St'}
    ]
)

if jack.is_valid:
    print jack.to_json(indent=2)
else:
    print json.dumps(dict(jack.validation_errors))
{
  "email": "[email protected]",
  "login": "jack",
  "token": {
    "secret": "ds5ds4xxx",
    "key": "vs7dfxxx"
  },
  "name": "Jack",
  "addresses": [
    {
      "line_1": "Main St",
      "line_2": null
    },
    {
      "line_1": "Main Street",
      "line_2": null
    }
  ]
}

Installation

You can install the last stable release of Booby from PyPI using pip or easy_install.

$ pip install booby

Also you can install the latest sources from Github.

$ pip install -e git+git://github.com/jaimegildesagredo/booby.git#egg=booby

Tests

To run the Booby test suite you should install the development requirements and then run nosetests.

$ pip install -r test-requirements.txt
$ nosetests tests/unit
$ nosetests tests/integration

Changes

See Changes.