Skip to content

neilpa/yajsv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7d7fbe5 · Sep 22, 2022

History

67 Commits
Mar 23, 2020
Sep 18, 2020
Mar 21, 2020
Jan 24, 2020
Apr 17, 2022
Sep 22, 2022
Oct 6, 2020
Apr 17, 2022
Apr 17, 2022
Oct 6, 2020
Oct 6, 2020

Repository files navigation

yajsv

CI

Yet Another JSON-Schema Validator. Command line tool for validating JSON and/or YAML documents against provided schemas.

The real credit goes to xeipuuv/gojsonschema which does the heavy lifting behind this CLI.

Installation

Simply use go install to install

go install github.com/neilpa/yajsv

There are also pre-built static binaries for Windows, Mac and Linux on the releases tab.

Usage

Yajsv validates JSON (and/or YAML) documents against a JSON-Schema, providing a status per document:

  • pass: Document is valid relative to the schema
  • fail: Document is invalid relative to the schema
  • error: Document is malformed, e.g. not valid JSON or YAML

The 'fail' status may be reported multiple times per-document, once for each schema validation failure.

Basic usage example

$ yajsv -s schema.json document.json
document.json: pass

Or with both schema and doc in YAML.

$ yajsv -s schema.yml document.yml
document.yml: pass

With multiple schema files and docs

$ yajsv -s schema.json -r foo.json -r bar.yaml doc1.json doc2.yaml
doc1.json: pass
doc2.json: pass

Or with file globs (note the quotes to side-step shell expansion)

$ yajsv -s main.schema.json -r '*.schema.json' 'docs/*.json'
docs/a.json: pass
docs/b.json: fail: Validation failure message
...

Note that each referenced schema is assumed to be a path on the local filesystem. These are not URI references to either local or external files.

See yajsv -h for more details

License

MIT