@hestia-earth/schema-validation 15.2.0 → 16.0.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.
Files changed (2) hide show
  1. package/README.md +26 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,33 @@
1
1
  # Hestia Schema Validation
2
2
 
3
- Module to validate data using the Hestia Schema and Ajv
3
+ Module to validate data using the Hestia Schema and Ajv.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- npm install @hestia-earth/schema-validation
8
+ npm install @hestia-earth/schema @hestia-earth/schema-validation
9
+ ```
10
+
11
+ ## Example validating JSON
12
+
13
+ ```javascript
14
+ const { SchemaType } = require('@hestia-earth/schema');
15
+ const { validator } = require('@hestia-earth/schema-validation/validate');
16
+
17
+ // Set to `true` to validate existing Nodes (@type/@id) or `false` for Nodes to upload (type/id)
18
+ const strictMode = false;
19
+ // Initialise the validation function, do this only once
20
+ const schemaValidation = validator(undefined, strictMode);
21
+
22
+ const node = {
23
+ type: SchemaType.Cycle,
24
+ id: 'my first cycle'
25
+ };
26
+
27
+ (async () => {
28
+ const { success, errors } = await schemaValidation(node);
29
+ console.log(success);
30
+ // list of errors in Ajv formatting. See https://github.com/ajv-validator/ajv/tree/v6.12.6#validation-errors
31
+ console.log(errors);
32
+ })();
9
33
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/schema-validation",
3
- "version": "15.2.0",
3
+ "version": "16.0.0",
4
4
  "description": "Hestia Schema Validation",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",