Simple proof-of-concept to validate STAC Items, Catalogs, Collections and core extensions with node.
See the STAC Validator Comparison for the features supported by this validator and the others out there.
Current version: 1.2.2
STAC Node Validator Version | Supported STAC Versions |
---|---|
1.1.0 / 1.2.x | >= 1.0.0-rc.1 |
0.4.x / 1.0.x | >= 1.0.0-beta.2 and < 1.0.0-rc.3 |
0.3.0 | 1.0.0-beta.2 |
0.2.1 | 1.0.0-beta.1 |
npx stac-node-validator /path/to/your/file-or-folder
to temporarily install the library and validate the provided file for folder. See the chapters below for advanced usage options.npm install -g stac-node-validator
to install the library permanentlystac-node-validator /path/to/your/file.json
stac-node-validator /path/to/your/catalog.json /path/to/your/item.json
Instead of paths to local files, you can also use HTTP(S) URLs. Other protocols such as S3 are not supported yet.
json
files in examples
folders): stac-node-validator ./stac-spec
Further options to add to the commands above:
dev
branch): --schemas /path/to/stac/folder
--schemaMap https://stac-extensions.github.io/foobar/v1.0.0/schema.json=./json-schema/schema.json
--ignoreCerts
--verbose
to get a more detailed output--strict
to enable strict mode in validation for schemas and numbers (as defined by ajv for options strictSchema
, strictNumbers
and strictTuples
)--lint
(add --verbose
to get a diff with the changes required)--format
(Attention: this will override the source files without warning!)Note on API support: Validating lists of STAC items/collections (i.e. GET /collections
and GET /collections/:id/items
) is partially supported.
It only checks the contained items/collections, but not the other parts of the response (e.g. links
).
You can also pass a config file via the --config
option. Simply pass a file path as value.
Parameters set via CLI will override the corresponding setting in the config file.
Make sure to use the value false
to override boolean flags that are set to true
in the config file.
The config file uses the same option names as above.
To specify the files to be validated, add an array with paths.
The schema map is an object instead of string separated with a =
character.
Example:
{
"files": [
"/path/to/your/catalog.json",
"/path/to/your/item.json"
],
"schemas": "/path/to/stac/folder",
"schemaMap": {
"https://stac-extensions.github.io/foobar/v1.0.0/schema.json": "./json-schema/schema.json"
},
"ignoreCerts": false,
"verbose": false,
"lint": true,
"format": false,
"strict": true
}
You could now override some options as follows in CLI: stac-node-validator example.json --config /path/to/config.json --lint false
git clone https://github.com/stac-utils/stac-node-validator
to clone the repocd stac-node-validator
to switch into the new folder created by gitnpm install
to install dependenciesstac-node-validator
with node bin/cli.js
, for example node bin/cli.js /path/to/your/file.json
Simply run npm test
in a working development environment.
If you want to disable tests for your fork of the repository, simply delete .github/workflows/test.yaml
.
Version | Tag | Published |
---|---|---|
1.2.2 | latest | 2yrs ago |