From bba7ce28268dfa52e29c6d516f91024624acbb29 Mon Sep 17 00:00:00 2001 From: Ken Brooks <kenneth.s.brooks@chase.com> Date: Sat, 21 Mar 2020 15:57:20 -0400 Subject: [PATCH] updating printed help and README --- README.md | 19 ++++++++++++++++--- main.go | 6 +++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9260b29..58a1e77 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [](https://github.com/neilpa/yajsv/actions/) -Yet Another [JSON-Schema](https://json-schema.org) Validator. Command line tool for validating JSON documents against provided schemas. +Yet Another [JSON-Schema](https://json-schema.org) Validator. Command line tool for validating JSON and YAML documents against provided schemas. The real credit goes to [xeipuuv/gojsonschema](https://github.com/xeipuuv/gojsonschema) which does the heavy lifting behind this CLI. @@ -18,21 +18,34 @@ There are also pre-built static binaries for Windows, Mac and Linux on the [rele ## Usage -yajsv validates JSON documents against a schema, providing a status per document: +yajsv validates JSON and YAML documents against a 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 + * 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 +Any combination can be used for schema and document. For example you can use a JSON schema to validate a YAML document. + + +Basic usage example + ``` $ yajsv -s schema.json document.json document.json: pass ``` +Basic usage example with YAML schema and document: + +``` +$ yajsv -s schema.yml document.yml +document.yml: pass +``` + + With multiple schema files and docs ``` diff --git a/main.go b/main.go index 8eb9626..2dd5013 100644 --- a/main.go +++ b/main.go @@ -190,14 +190,14 @@ func jsonLoader(path string) (gojsonschema.JSONLoader, error) { } func printUsage() { - fmt.Fprintf(os.Stderr, `Usage: %s -s schema.json [options] document.json ... + fmt.Fprintf(os.Stderr, `Usage: %s -s schema.json|schema.yml [options] document.json|document.yml ... - yajsv validates JSON document(s) against a schema. One of three statuses are + yajsv validates JSON and YAML document(s) against a schema. One of three statuses are reported 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 + 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. -- GitLab