@cfworker/json-schema 1.12.3 → 1.12.5
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/README.md +5 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -10,14 +10,14 @@ A JSON schema validator that will run on Cloudflare workers. Supports drafts 4,
|
|
|
10
10
|
|
|
11
11
|
This library is validated against the [json-schema-test-suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite), a series of approximately 4,500 assertions maintained along with the json-schema specification. A small set of test cases are intentionally not supported due to performance constraints or lack of feature use. These list of unsupported features are maintained in [test/unsupported.ts](./test/unsupported.ts). While this library is not the fastest due to lack of code generation, it's consistently among the [most spec compliant](https://json-schema.org/implementations.html#benchmarks).
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Background
|
|
14
14
|
|
|
15
15
|
_Why another JSON schema validator?_
|
|
16
16
|
|
|
17
17
|
Cloudflare workers do not have APIs required by [Ajv](https://ajv.js.org/) schema compilation (`eval` or `new Function(code)`).
|
|
18
18
|
If possible use Ajv in a build step to precompile your schema. Otherwise this library could work for you.
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Basic usage
|
|
21
21
|
|
|
22
22
|
```js
|
|
23
23
|
import { Validator } from '@cfworker/json-schema';
|
|
@@ -27,13 +27,13 @@ const validator = new Validator({ type: 'number' });
|
|
|
27
27
|
const result = validator.validate(7);
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
##
|
|
30
|
+
## Specify meta schema draft
|
|
31
31
|
|
|
32
32
|
```js
|
|
33
33
|
const validator = new Validator({ type: 'number' }, '4'); // draft-4
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## Add schemas
|
|
37
37
|
|
|
38
38
|
```js
|
|
39
39
|
const validator = new Validator({
|
|
@@ -44,7 +44,7 @@ const validator = new Validator({
|
|
|
44
44
|
validator.addSchema({ $id: 'https://foo.bar/beep', type: 'boolean' });
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
##
|
|
47
|
+
## Include all errors
|
|
48
48
|
|
|
49
49
|
By default the validator stops processing after the first error. Set the `shortCircuit` parameter to `false` to emit all errors.
|
|
50
50
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfworker/json-schema",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.12.
|
|
4
|
+
"version": "1.12.5",
|
|
5
5
|
"description": "A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"json-schema",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"test": "cfworker test test/**/*.spec.ts --nocheck"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@cfworker/dev": "^1.14.
|
|
42
|
-
"@types/chai": "^4.3.
|
|
43
|
-
"@types/mocha": "^
|
|
41
|
+
"@cfworker/dev": "^1.14.2",
|
|
42
|
+
"@types/chai": "^4.3.3",
|
|
43
|
+
"@types/mocha": "^10.0.0",
|
|
44
44
|
"chai": "^4.3.6",
|
|
45
45
|
"json-schema-test-suite": "git+https://github.com/json-schema-org/JSON-Schema-Test-Suite#76b529f",
|
|
46
|
-
"mocha": "^
|
|
47
|
-
"typescript": "^4.
|
|
46
|
+
"mocha": "^10.0.0",
|
|
47
|
+
"typescript": "^4.8.4"
|
|
48
48
|
}
|
|
49
49
|
}
|