schema-markdown 1.1.2 → 1.1.3
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 +6 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -28,9 +28,10 @@ To schema-validate an object, first parse its *Schema Markdown* using the
|
|
|
28
28
|
class:
|
|
29
29
|
|
|
30
30
|
``` javascript
|
|
31
|
-
import
|
|
31
|
+
import {SchemaMarkdownParser} from 'schema-markdown/parser.js';
|
|
32
|
+
import {validateType} from 'schema-markdown/schema.js';
|
|
32
33
|
|
|
33
|
-
const parser = new
|
|
34
|
+
const parser = new SchemaMarkdownParser(`\
|
|
34
35
|
# An aggregation function
|
|
35
36
|
enum Aggregation
|
|
36
37
|
Average
|
|
@@ -51,7 +52,7 @@ Then, validate an object using the
|
|
|
51
52
|
function:
|
|
52
53
|
|
|
53
54
|
``` javascript
|
|
54
|
-
const obj =
|
|
55
|
+
const obj = validateType(parser.types, 'Operation', {
|
|
55
56
|
'numbers': [1, 2, '3', 4]
|
|
56
57
|
});
|
|
57
58
|
console.assert(obj.numbers[2] === 3);
|
|
@@ -62,7 +63,7 @@ Validation fails if the object does not match the schema:
|
|
|
62
63
|
|
|
63
64
|
``` javascript
|
|
64
65
|
try {
|
|
65
|
-
|
|
66
|
+
validateType(parser.types, 'Operation', {
|
|
66
67
|
'numbers': [1, 2, 'asdf', 4]
|
|
67
68
|
});
|
|
68
69
|
} catch ({message}) {
|
|
@@ -74,7 +75,7 @@ Validation also fails if a member contraint is violated:
|
|
|
74
75
|
|
|
75
76
|
``` javascript
|
|
76
77
|
try {
|
|
77
|
-
|
|
78
|
+
validateType(parser.types, 'Operation', {
|
|
78
79
|
'numbers': []
|
|
79
80
|
});
|
|
80
81
|
} catch ({message}) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "schema-markdown",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"description": "Human-friendly schema definition language and schema validator",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"schema",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"ava": "^4.0.0-rc.1",
|
|
28
28
|
"c8": "~7.10",
|
|
29
|
-
"eslint": "~8.
|
|
29
|
+
"eslint": "~8.4",
|
|
30
30
|
"jsdoc": "~3.6",
|
|
31
|
-
"jsdom": "~
|
|
31
|
+
"jsdom": "~19.0"
|
|
32
32
|
}
|
|
33
33
|
}
|