Check schema
The check tool is used to validate file(s) against a schema.
Prints the following options:
optional arguments:
-h, --help show this help message and exit
--input [ ...] input file(s) to check
--input-directory directory(s) of files to check
--schema schema definition file to compare
--fail-directory directory to move failed files to
--verbose, -v verbose output
--silent, -s silence output
--json-schema, -j validate as json schema
JSON Schema
Using --json-schema
will, if jsonschema
is installed, validate using the JSON Schema specification.
For support using JSON schema, install the Python package using:
Example:
Will print the following if passed:
Or if failed the test:
Note
If the input is piped and the input fails the check, the program exits with code 1.
Furthermore a message detailing the failure can be printed using --verbose
output, for example:
Type 'key_one' == 'string',
Required type 'integer' (per schema {'type': 'integer'}),
In {'key_one': '99', 'key_two': 'text'},
Path /root/dict_type/key_one
Should output be suppressed, adding the --silent
can be used.
Furthermore, input files that fail the check can be moved to directory using --fail-directory
: