diff --git a/README.md b/README.md index 9260b2944920599940230d10f55e363cd31a16d0..58a1e77a59caf293cf68e1658fa879d016e6c63c 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 8eb9626a747e3e47edc035709ac728f20f70d32d..2dd5013fefae0dccfc6f59d7b6f8896237b33fe3 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.