Git Product home page Git Product logo

validictory's Introduction

validictory

warning:โš ๏ธ As of 2018 this library is deprecated, please consider using jsonschema (https://pypi.python.org/pypi/jsonschema) instead.
https://travis-ci.org/jamesturk/validictory.svg?branch=master https://coveralls.io/repos/jamesturk/validictory/badge.png?branch=master Documentation Status

A general purpose Python data validator.

Works with Python 2.7 and Python 3.3+

Schema format based on JSON Schema Proposal (http://json-schema.org)

Contains code derived from jsonschema, by Ian Lewis and Yusuke Muraoka.

Usage

JSON documents and schema must first be loaded into a Python dictionary type before it can be validated.

Parsing a simple JSON document:

>>> import validictory
>>>
>>> validictory.validate("something", {"type":"string"})

Parsing a more complex JSON document:

>>> import json
>>> import validictory
>>>
>>> data = json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
>>> schema = {
...   "type":"array",
...   "items":[
...     {"type":"string"},
...     {"type":"object",
...      "properties":{
...        "bar":{
...          "items":[
...            {"type":"string"},
...            {"type":"any"},
...            {"type":"number"},
...            {"type":"integer"}
...          ]
...        }
...      }
...    }
...   ]
... }
>>> validictory.validate(data,schema)

Catch ValueErrors to handle validation issues:

>>> import validictory
>>>
>>> try:
...     validictory.validate("something", {"type":"string","minLength":15})
... except ValueError, error:
...     print(error)
...
Length of value 'something' for field '_data' must be greater than or equal to 15

You can read more in the official documentation at Read the Docs.

validictory's People

Contributors

aconrad avatar ahassany avatar alfredodeza avatar alonho avatar andruskutt avatar boblannon avatar cd3 avatar chrigrahcisco avatar dokai avatar eisensheng avatar filod avatar heiko-san avatar htgoebel avatar jamesturk avatar juanmb avatar mgrandi avatar mikejs avatar mmariani avatar msabramo avatar nickstefan avatar nicolaiarocci avatar onyxfish avatar peritus avatar rhettg avatar rkrzr avatar sebjamesfd avatar silas avatar simon-weber avatar talos 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.