Skip to main content

Booby: data modeling and validation

Latest version License 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.

This is an active fork.

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='jack@example.com',
    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": "jack@example.com",
  "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.

Metadata

Release files for metabooby 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metabooby 0.10.0
File Size Uploaded
metabooby-0.10.0.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metabooby 0.10.0
File Interpreter ABI Platform
metabooby-0.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / metabooby-0.10.0.tar.gz

Download URL metabooby-0.10.0.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e160e8ba6538cabff965115495809e3648a1c3e2b3392a23252284ccb7b0d2f1
BLAKE2b-256 checksum
How to use checksums
a551329f922fbf0c2a4a2a8cda96920fb647e192f65d3d3d1c303099fd0b05aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.10

Release files / metabooby-0.10.0-py3-none-any.whl

Download URL metabooby-0.10.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e545da344ac9b744528bc58bd27010ab1b67e791067adfa00b529814470a65cc
BLAKE2b-256 checksum
How to use checksums
7a3057eebd39e52964824d244bc4f545018ffa882bc5350af0f8dcb1336a6d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page