Skip to main content

Cacheable schema description and validation

Project description

https://readthedocs.org/projects/conformity/badge/ https://pepy.tech/badge/conformity https://img.shields.io/pypi/l/conformity.svg https://api.travis-ci.org/eventbrite/conformity.svg https://img.shields.io/pypi/v/conformity.svg https://img.shields.io/pypi/wheel/conformity.svg https://img.shields.io/pypi/pyversions/conformity.svg

Conformity is a declarative schema validation library designed for use in libraries, services, application settings, and more.


Declare a schema:

from conformity.fields import Dictionary, Float, Integer, List, UnicodeString

person = Dictionary({
    "name": UnicodeString(),
    "height": Float(gte=0),
    "event_ids": List(Integer(gt=0)),
})

Check to see if data is valid:

data = {"name": "Andrew", "height": 180.3, "event_ids": [1, "3"]}
errors = person.errors(data)

# Key event_ids: Index 1: Not an integer

And wrap functions to validate on the way in and out:

kwargs = Dictionary({
    "name": UnicodeString(),
    "score": Integer(),
}, optional_keys=["score"])

@validate_call(kwargs, UnicodeString())
def greet(name, score=0):
    if score > 10:
        return "So nice to meet you, {}!".format(name)
    else:
        return "Hello, {}.".format(name)

There’s support for basic string, numeric, geographic, temporal, networking, and other field types, with everything easily extensible (optionally via subclassing). Conformity also boasts support for full-blown application settings schema definition and validation complete with definable defaults, and includes Sphinx autodoc extensions to help you generate meaningful documentation for your code using Conformity.

License

Conformity is licensed under the Apache License, version 2.0.

Installation

Conformity is available in PyPi and can be installing directly via Pip or listed in setup.py, requirements.txt, or Pipfile:

pip install 'conformity~=1.26'
install_requires=[
    ...
    'conformity~=1.26',
    ...
]
conformity~=1.26
conformity = {version="~=1.26"}

Documentation

The complete Conformity documentation is available on Read the Docs!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conformity-1.27.2.tar.gz (40.6 kB view details)

Uploaded Source

Built Distribution

conformity-1.27.2-py27.py35.py36.py37.py38-none-any.whl (50.9 kB view details)

Uploaded Python 2.7 Python 3.5 Python 3.6 Python 3.7 Python 3.8

File details

Details for the file conformity-1.27.2.tar.gz.

File metadata

  • Download URL: conformity-1.27.2.tar.gz
  • Upload date:
  • Size: 40.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.7

File hashes

Hashes for conformity-1.27.2.tar.gz
Algorithm Hash digest
SHA256 4bfe2490012d46eb59ce21ea4294d46197bd6aa329ce7b660699d7386e4e818d
MD5 0bf9dcd7deecc5a7dafe5dc0031c893e
BLAKE2b-256 87ec0de18baa3fe23056be4848540eaa01f6b94a4948aab57968aea4e9a56121

See more details on using hashes here.

File details

Details for the file conformity-1.27.2-py27.py35.py36.py37.py38-none-any.whl.

File metadata

  • Download URL: conformity-1.27.2-py27.py35.py36.py37.py38-none-any.whl
  • Upload date:
  • Size: 50.9 kB
  • Tags: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.7

File hashes

Hashes for conformity-1.27.2-py27.py35.py36.py37.py38-none-any.whl
Algorithm Hash digest
SHA256 4308725450e9a66cb68c73d111a58eee5f4e5281790a3dc6553fef4a5c485ac6
MD5 9cbe2d9e866c63a55d60342deb6787ba
BLAKE2b-256 2482a0c81643b1e17ffdbe0431bef24472d824f88fd2d83e2e2adca651edfcf7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page