GithubHelp home page GithubHelp logo

isabella232 / conformity Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juancuello/conformity

0.0 0.0 0.0 414 KB

License: Apache License 2.0

Python 99.25% Dockerfile 0.22% Shell 0.05% JavaScript 0.48%

conformity's Introduction

Conformity - Declarative Schema for Python

image

image

image

image

image

image

image

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!

conformity's People

Contributors

andrewgodwin avatar eb-diegomunoz avatar eb-francisco avatar gabrielf-eb avatar jshuping avatar michaelmanganiello-eb avatar nickwilliams-eventbrite avatar ravila-eb avatar sethbrite avatar vartec avatar yanguo-eb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.