Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2 #74

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
50c66e3
Rewritten the code for more features and to extract validation, v2.0.…
m-mohr Aug 10, 2023
a74e9fe
Implement custom validation + doc improvements
m-mohr Sep 7, 2023
043bbcb
2.0.0-beta.2
m-mohr Sep 7, 2023
0f04671
fix various issues, v2.0.0-beta.3
m-mohr Sep 7, 2023
2491e0d
fix CLI output issues, v2.0.0-beta.4
m-mohr Oct 6, 2023
ef062ff
fix CLI output issues, v2.0.0-beta.5
m-mohr Oct 6, 2023
2d9f06f
Add funding info
m-mohr Feb 14, 2024
798731f
Restructure
m-mohr Mar 15, 2024
776de0b
Implement temporary workaround for https://github.com/OSGeo/PROJ/issu…
m-mohr Mar 15, 2024
bf48fe0
v2.0.0-beta.6
m-mohr Mar 15, 2024
d2d441b
clean-up
m-mohr Mar 15, 2024
8b364b4
Fix validation of iri without a host (i.e. localhost)
m-mohr Mar 20, 2024
48faec6
v2.0.0-beta.7
m-mohr Mar 20, 2024
f848077
Revert "Implement temporary workaround for https://github.com/OSGeo/P…
m-mohr Mar 26, 2024
98ede5f
Handle schemas that have no $id defined
m-mohr Jul 19, 2024
0f80500
Import doesn't work
m-mohr Jul 19, 2024
445af98
v2.0.0-beta.8
m-mohr Jul 19, 2024
fd598cf
Report data loading issues
m-mohr Aug 5, 2024
57c0922
Add missing uri-js dependency, v2.0.0-beta.9
m-mohr Aug 5, 2024
35a29de
Fix missing import, v2.0.0-beta.10
m-mohr Aug 5, 2024
c3cffc3
Fix linting report, v2.0.0-beta.11
m-mohr Aug 5, 2024
a9a99a3
Allow to customize Ajv via custom validator, v2.0.0-beta.12
m-mohr Aug 7, 2024
1894549
Don't run MacOS 11 CI anylonger
m-mohr Oct 31, 2024
9af3ed4
Merge branch 'master' into v2
m-mohr Oct 31, 2024
7a84f42
Check against more current node versions
m-mohr Oct 31, 2024
80fef01
Add possibility to bypass validator
m-mohr Oct 31, 2024
c5e8dd8
v2.0.0-beta.13
m-mohr Oct 31, 2024
d88b9ed
Support for partial URLs in schema maps
m-mohr Jan 30, 2025
3628d0a
Support for JS config files
m-mohr Jan 30, 2025
1f44231
Handle invalid input paths better
m-mohr Jan 30, 2025
7202d53
Better URL parsing and handling of unsupported protocols
m-mohr Jan 30, 2025
7e39c5e
v2.0.0-beta.14
m-mohr Jan 30, 2025
8611efb
Fix reference error
m-mohr Jan 30, 2025
f128999
Fix various issues of the last release
m-mohr Jan 30, 2025
f6d7cdb
v2.0.0-beta.15
m-mohr Jan 30, 2025
75b6529
Update stac-js
m-mohr Jan 30, 2025
9553f84
Update README.md
m-mohr Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
fail-fast: false
matrix:
runner: [
'macos-11',
'macos-12',
'macos-13',
'macos-latest',
Expand All @@ -22,7 +21,7 @@ jobs:
'windows-2022',
'windows-latest',
]
node: [ '16', '18', '20', '22', 'lts/*' ]
node: [ '18', '20', '22', '23', 'lts/*' ]
runs-on: ${{ matrix.runner }}
name: ${{ matrix.runner }} runner with Node.js ${{ matrix.node }}
steps:
Expand Down
8 changes: 4 additions & 4 deletions COMPARISON.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Here I'd like to give an overview of what the validators are capable of and what

| | Python Validator | PySTAC | STAC Node Validator |
| :------------------------- | ------------------------------------------ | ------------------- | ------------------- |
| Validator Version | 1.0.1 | 0.5.2 | 1.3.1 |
| Validator Version | 1.0.1 | 0.5.2 | 2.0.0 |
| Language | Python 3.6 | Python 3 | NodeJS |
| CLI | Yes | No | Yes |
| Programmatic | Yes | Yes | Planned |
| Online | Yes, [staclint.com](https://staclint.com/) | No | Planned |
| Programmatic | Yes | Yes | Yes |
| Online | Yes, [staclint.com](https://staclint.com/) | No | Yes |
| Protocols supported (Read) | HTTP(S), Filesystem | HTTP(S), Filesystem | HTTP(S), Filesystem |
| Gives | HTML / CLI / Python Output | Python Dict | CLI output |
| Gives | HTML / CLI / Python | Python | CLI / JavaScript |

## Specifications supported

Expand Down
32 changes: 5 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ See the [STAC Validator Comparison](COMPARISON.md) for the features supported by

## Versions

**Current version: 1.3.1**
**Current version:** 2.0.0-beta.15

| STAC Node Validator Version | Supported STAC Versions |
| --------------------------- | ----------------------- |
| 1.1.0 / 1.2.x | >= 1.0.0-rc.1 |
| 1.1.0 / 1.2.x / 2.x.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 |
Expand All @@ -22,7 +22,7 @@ See the [STAC Validator Comparison](COMPARISON.md) for the features supported by

## Setup

1. Install [node and npm](https://nodejs.org) - should run with any version >= 16. Older versions may still work, but no guarantee.
1. Install [node and npm](https://nodejs.org) - should run with any version >= 22.1.0.
2. `npm install -g stac-node-validator` to install the library permanently

## Usage
Expand All @@ -44,42 +44,20 @@ Further options to add to the commands above:
- Add `--strict` to enable strict mode in validation for schemas and numbers (as defined by [ajv](https://ajv.js.org/strict-mode.html) for options `strictSchema`, `strictNumbers` and `strictTuples`)
- To lint local JSON files: `--lint` (add `--verbose` to get a diff with the changes required)
- To format / pretty-print local JSON files: `--format` (Attention: this will override the source files without warning!)
- To run custom validation code: `--custom ./path/to/validation.js` - The validation.js needs to contain a class that implements the `BaseValidator` interface. See [custom.example.js](./custom.example.js) for an example.

**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`).

### Config file

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.
Parameters set via CLI will not override the corresponding setting 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:**
```json
{
"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,
"all": false
}
```

You could now override some options as follows in CLI: `stac-node-validator example.json --config /path/to/config.json --lint false`

### Development

1. `git clone https://github.com/stac-utils/stac-node-validator` to clone the repo
Expand Down
3 changes: 2 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env node
require('../index.js')()
const runCLI = require('../src/cli.js');
runCLI();
25 changes: 25 additions & 0 deletions custom.example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const BaseValidator = require('stac-node-validator/src/baseValidator.js');

class CustomValidator extends BaseValidator {

/**
* Any custom validation routines you want to run.
*
* You can either create a list of errors using the test interface
* or just throw on the first error.
*
* @param {STAC} data
* @param {Test} test
* @param {import('.').Report} report
* @param {import('.').Config} config
* @throws {Error}
*/
async afterValidation(data, test, report, config) {
if (data.id === 'solid-earth') {
test.deepEqual(data.example, [1,2,3]);
}
}

}

module.exports = CustomValidator;
Loading
Loading