Skip to main content

RAC JSON Schemas and validators

Project description

rac_schemas

JSON schemas and validation helpers.

Requirements

  • Python 3.4 or higher

  • jsonschema

  • tox (for running tests)

  • pre-commit (for running linters before committing)

    • After installing pre-commit, install the git-hook scripts:
    $ pre-commit install
    

Installation

The recommended way to install this package is using pip:

pip install rac_schemas

Usage

This library has one main public method, is_valid(), which takes a dict as the first argument and a schema filename as the second.

from rac_schemas import is_valid

data = {"key": "value" ... }
is_valid(data, "object.json")

rac_schemas will attempt to add an appropriate extension to schema filenames in cases where it is either missing or incorrect. For example, if either schema and schema.org as schema filenames, rac_schemas will attempt to open schema.json.

Invalid data will raise a jsonschema.exceptions.ValidationError, and an invalid schema filename will raise a FileNotFoundError.

Available schemas

All schemas are located in the schemas/ subdirectory of the rac_schemas/ directory.

Tests

rac_schemas comes with unit tests as well as linting. The easiest way to make sure all tests pass is to run tox from the root of the repository. This will execute all tests, and will also run autopep8 and flake8 linters against the codebase.

License

Code is released under an MIT license. SeeLICENSE.md.

Project details


Download files

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

Files for rac-schemas, version 0.6
Filename, size File type Python version Upload date Hashes
Filename, size rac_schemas-0.6-py3-none-any.whl (12.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size rac_schemas-0.6.tar.gz (9.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page