check-jsonschema

0.37.1 · active · verified Thu Apr 09

check-jsonschema is a command-line interface (CLI) tool and pre-commit hook for validating JSON/YAML files against JSON schemas. It provides a convenient way to integrate schema validation into development workflows, supporting a wide range of common configuration schemas. The current version is 0.37.1, and it releases frequently to update vendored schemas and add new features.

Warnings

Install

Imports

Quickstart

The primary use of check-jsonschema is through its command-line interface or as a pre-commit hook. First, define your JSON schema and the data you wish to validate. Then, run the `check-jsonschema` command specifying the schema and data files. For automated checks, configure it in your `.pre-commit-config.yaml` file, using its built-in hooks for common configuration files or a custom hook for your own schemas.

# 1. Create a schema file (e.g., 'my_schema.json')
# echo '{"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]}' > my_schema.json

# 2. Create a data file to validate (e.g., 'my_data.json')
# echo '{"name": "John Doe"}' > my_data.json

# 3. Run validation via CLI
# check-jsonschema --schema my_schema.json my_data.json

# 4. Integrate with pre-commit (add to .pre-commit-config.yaml)
#    - repo: https://github.com/python-jsonschema/check-jsonschema
#      rev: '0.37.1'
#      hooks:
#        - id: check-dependabot
#        - id: check-github-workflows

view raw JSON →