Reading from Stdin
The validator can read input from stdin instead of traversing the filesystem. Use - as the search path and specify the file type with --file-types.
Basic usage
echo '{"key": "value"}' | validator --file-types=json -
cat config.yaml | validator --file-types=yaml -
Requirements
- The search path must be exactly
- -must be the only search path — it cannot be combined with other paths--file-typesmust specify exactly one file type- Input is read until EOF
Use cases
Validate config fetched from a remote source:
curl -s https://config-service.internal/app.json | validator --file-types=json -
Validate the output of a template engine or merge tool — the processed result, not the source file:
helm template my-chart | validator --file-types=yaml -
envsubst < config.template.yaml | validator --file-types=yaml -
Behavior
When reading from stdin:
- The validator reads all input, parses it as the specified type, and reports pass or fail.
- Schema validation applies if the content declares a schema (e.g., a
$schemaproperty in JSON). --schema-mappatterns do not apply since there is no filename to match against.- The reported filename in output is
stdin. - Exit codes are the same as filesystem mode:
0for valid,1for invalid.