Skip to content
/ pykwalify Public
forked from Grokzen/pykwalify

Python JSON/YAML schema validation library

Notifications You must be signed in to change notification settings

mrab/pykwalify

 
 

Repository files navigation

pyKwalify

Build Status Coverage Status ![Gitter](https://badges.gitter.im/Join Chat.svg)

YAML/JSON validation library

This framework is a port with alot added functionality of the java version of the framework kwalify that can be found at: http://www.kuwata-lab.com/kwalify/

The source code can be found at: http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/

The schema this library is base and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema

Installation

Latest stable release from pypi

$ pip install pykwalify

or from source

$ python setup.py install

Usage

Create a data file. Json and yaml formats are both supported.

- foo
- bar

Create a schema file with validation rules.

type: seq
sequence:
  - type: str

Run validation from cli.

pykwalify --data-file data.yaml --schema-file schema.yaml

If validation passes then return code from the invocation will be 0. If errors was found then 1.

Run validation from code. Multiple schema files is possible to use when using partial schemas (See doc for details).

from pykwalify.core import Core
c = Core(source_file="data.yaml", schema_files=["schema.yaml"])
c.validate(raise_exception=True)

If validation fails then exception will be raised.

Runtime Dependencies

  • docopt >= 0.6.2
  • PyYaml >= 3.11
  • python-dateutil >= 2.4.2

Supported python version

  • Python 2.7
  • Python 3.3
  • Python 3.4
  • Python 3.5 (Currently up to beta 4 release)

How to test

Install test requirements with

$ pip install -r dev-requirements.txt

Run tests with

$ py.test

or if you want to test against all python versions and pep8

$ tox

Documentation

  • [Implemented validation rules](docs/Validation Rules.md)
  • Extensions
  • [Upgrade instructions](docs/Upgrade Instructions.md)
  • Release notes

Licensing

MIT, See docs/License.txt for details

Copyright (c) 2013-2015 Johan Andersson

About

Python JSON/YAML schema validation library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.8%
  • Makefile 1.2%