schemata-validator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/bin/cli.js +5 -0
- package/data/classes.json +3748 -0
- package/data/properties.json +8274 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +24 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants.d.ts +46 -0
- package/dist/constants.js +47 -0
- package/dist/constants.js.map +1 -0
- package/dist/format-parsers/html-parser.d.ts +15 -0
- package/dist/format-parsers/html-parser.js +32 -0
- package/dist/format-parsers/html-parser.js.map +1 -0
- package/dist/format-parsers/json-ld-parser.d.ts +34 -0
- package/dist/format-parsers/json-ld-parser.js +96 -0
- package/dist/format-parsers/json-ld-parser.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/schemata-validator.d.ts +19 -0
- package/dist/schemata-validator.js +69 -0
- package/dist/schemata-validator.js.map +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/browse-folders.d.ts +6 -0
- package/dist/utils/browse-folders.js +18 -0
- package/dist/utils/browse-folders.js.map +1 -0
- package/dist/utils/display-cli-flags.d.ts +5 -0
- package/dist/utils/display-cli-flags.js +24 -0
- package/dist/utils/display-cli-flags.js.map +1 -0
- package/dist/utils/display-reporting.d.ts +7 -0
- package/dist/utils/display-reporting.js +38 -0
- package/dist/utils/display-reporting.js.map +1 -0
- package/dist/utils/dry-run-notice.d.ts +4 -0
- package/dist/utils/dry-run-notice.js +8 -0
- package/dist/utils/dry-run-notice.js.map +1 -0
- package/dist/utils/get-file-content.d.ts +6 -0
- package/dist/utils/get-file-content.js +10 -0
- package/dist/utils/get-file-content.js.map +1 -0
- package/dist/utils/get-files-to-validate.d.ts +9 -0
- package/dist/utils/get-files-to-validate.js +37 -0
- package/dist/utils/get-files-to-validate.js.map +1 -0
- package/dist/utils/parse-args.d.ts +7 -0
- package/dist/utils/parse-args.js +47 -0
- package/dist/utils/parse-args.js.map +1 -0
- package/dist/utils/pattern-to-regex.d.ts +6 -0
- package/dist/utils/pattern-to-regex.js +15 -0
- package/dist/utils/pattern-to-regex.js.map +1 -0
- package/dist/utils/prepare-reporting.d.ts +8 -0
- package/dist/utils/prepare-reporting.js +22 -0
- package/dist/utils/prepare-reporting.js.map +1 -0
- package/dist/utils/show-help.d.ts +4 -0
- package/dist/utils/show-help.js +13 -0
- package/dist/utils/show-help.js.map +1 -0
- package/dist/utils/show-version.d.ts +4 -0
- package/dist/utils/show-version.js +8 -0
- package/dist/utils/show-version.js.map +1 -0
- package/dist/validator/schema-graph-validator.d.ts +46 -0
- package/dist/validator/schema-graph-validator.js +164 -0
- package/dist/validator/schema-graph-validator.js.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Victor Brito
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# schemata-validator
|
|
2
|
+
|
|
3
|
+
Check the validity of Schema.org vocabulary used in JSON-LD data
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
[](https://nodejs.org/api/esm.html)
|
|
7
|
+
[](https://conventionalcommits.org)
|
|
8
|
+
[](https://biomejs.dev)
|
|
9
|
+
[](https://github.com/release-change/release-change)
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
**schemata-validator** takes JSON-LD and HTML files using JSON-LD data and returns detailed validation results.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Install package for Node.js:
|
|
19
|
+
```
|
|
20
|
+
pnpm add --save-dev schemata-validator
|
|
21
|
+
```
|
|
22
|
+
You can also install it using `npm`:
|
|
23
|
+
```
|
|
24
|
+
npm install --save-dev schemata-validator
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Options
|
|
30
|
+
|
|
31
|
+
##### data
|
|
32
|
+
|
|
33
|
+
Type: `array`
|
|
34
|
+
|
|
35
|
+
Specifies which JSON-LD data to be sent to validation. This option takes precedence over the other options.
|
|
36
|
+
|
|
37
|
+
##### files
|
|
38
|
+
|
|
39
|
+
Type: `array`
|
|
40
|
+
CLI arguments: `-f <space-separated list of files>`, `--files <space-separated list of files>`
|
|
41
|
+
|
|
42
|
+
Specifies which files to be sent to validation. This option takes precedence over the other options.
|
|
43
|
+
|
|
44
|
+
##### paths
|
|
45
|
+
|
|
46
|
+
Type: `array`
|
|
47
|
+
CLI arguments: `-p <space-separated list of paths>`, `--paths <space-separated list of paths>`
|
|
48
|
+
|
|
49
|
+
Specifies which folders or files to be sent to validation. When omitted, all files are validated (skipping the `node_modules` folder), unless the `exclude` option is specified.
|
|
50
|
+
|
|
51
|
+
##### exclude
|
|
52
|
+
|
|
53
|
+
Type: `array`
|
|
54
|
+
CLI arguments: `-e <space-separated list of paths>`, `--exclude <space-separated list of paths>`
|
|
55
|
+
|
|
56
|
+
Lists strings to match in paths to skip. When omitted, all files specified by `files` options if defined (all files otherwise) are validated (skipping the `node_modules` folder).
|
|
57
|
+
|
|
58
|
+
##### dryRun
|
|
59
|
+
|
|
60
|
+
Type: `boolean`
|
|
61
|
+
Default: `false`
|
|
62
|
+
CLI arguments: `-d`, `--dry-run`
|
|
63
|
+
|
|
64
|
+
Bypasses the validation (for usage while building CI).
|
|
65
|
+
|
|
66
|
+
### CLI
|
|
67
|
+
|
|
68
|
+
schemata-validator can be used as a CLI tool.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
schemata-validator [flags]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### `package.json` scripts
|
|
75
|
+
|
|
76
|
+
You can run `schemata-validator` from the `scripts` section of your `package.json` file.
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"scripts": {
|
|
81
|
+
"one-folder": "schemata-validator --paths docs",
|
|
82
|
+
"one-file": "schemata-validator --files docs/index.html",
|
|
83
|
+
"all-files": "schemata-validator"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Examples
|
|
89
|
+
|
|
90
|
+
- `schemata-validator`: validates all HTML files using JSON-LD data in the project;
|
|
91
|
+
- `schemata-validator --paths docs --exclude build tmp`: validates all HTML files using JSON-LD data in the `docs/` folder, except files which have `build` or `tmp` anywhere in their pathname or filename;
|
|
92
|
+
- `schemata-validator --files docs/index.html`: validates only the specified files.
|
|
93
|
+
|
|
94
|
+
### Application code
|
|
95
|
+
|
|
96
|
+
In addition to the CLI interface, schemata-validator can be imported and called in ESM and TypeScript projects.
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
import { SchemataValidator } from "schemata-validator";
|
|
100
|
+
|
|
101
|
+
const jsonld = `{
|
|
102
|
+
"@context": "https://schema.org",
|
|
103
|
+
"@type": "WebPage",
|
|
104
|
+
"name": "Web page title",
|
|
105
|
+
"description": "Web page description"
|
|
106
|
+
}`;
|
|
107
|
+
const options = { data: [jsonld] };
|
|
108
|
+
const validator = new SchemataValidator(options);
|
|
109
|
+
const validate = await validator.validate();
|
|
110
|
+
validator.log(validate); // Outputs the reporting object
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Get help
|
|
114
|
+
|
|
115
|
+
- [Stack Overflow](https://stackoverflow.com/questions/tagged/schemata-validator)
|
|
116
|
+
|
|
117
|
+
## Copyright & licence
|
|
118
|
+
|
|
119
|
+
© 2026 Victor Brito — Released under the [MIT licence](./LICENSE).
|