@nsshunt/stsutils 1.6.0 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsutils",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,15 +22,15 @@
22
22
  "parser": "@babel/eslint-parser"
23
23
  },
24
24
  "devDependencies": {
25
- "@babel/core": "^7.17.0",
25
+ "@babel/core": "^7.17.2",
26
26
  "@babel/eslint-parser": "^7.17.0",
27
27
  "@babel/plugin-proposal-class-properties": "^7.16.7",
28
28
  "@babel/plugin-proposal-private-methods": "^7.16.11",
29
29
  "eslint": "^8.8.0",
30
- "jest": "^27.4.7"
30
+ "jest": "^27.5.1"
31
31
  },
32
32
  "dependencies": {
33
- "ajv": "^8.9.0",
33
+ "ajv": "^8.10.0",
34
34
  "axios": "^0.25.0",
35
35
  "colors": "^1.4.0",
36
36
  "debug": "^4.3.3"
package/stsoptionsbase.js CHANGED
@@ -1,3 +1,5 @@
1
+ const { Validate } = require('./validate.js');
2
+
1
3
  class STSOptionsBase
2
4
  {
3
5
  #options = null;
@@ -5,6 +7,15 @@ class STSOptionsBase
5
7
  constructor(options = null)
6
8
  {
7
9
  this.#options = options;
10
+
11
+ if (options !== null) {
12
+ if (typeof options.validator === 'undefined') {
13
+ console.log(JSON.stringify(options));
14
+ console.trace("Options Here ------------------------------------------------------------------------------------------")
15
+ } else {
16
+ Validate(options.validator, options);
17
+ }
18
+ }
8
19
  }
9
20
 
10
21
  /**
@@ -12,7 +23,8 @@ class STSOptionsBase
12
23
  */
13
24
  get Options()
14
25
  {
15
- return this.#options;
26
+ console.trace("Use of Options Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<----------------------------------------")
27
+ return this.#options;
16
28
  }
17
29
 
18
30
  get options()
package/validate.js CHANGED
@@ -2,12 +2,7 @@ const Ajv = require('ajv/dist/jtd');
2
2
 
3
3
  const ajv = new Ajv();
4
4
 
5
- const AddSchema = (name, schema) => {
6
- ajv.addSchema(schema, name)
7
- };
8
-
9
- const Validate = (name, payload) => {
10
- const validator = ajv.getSchema(name)
5
+ const _Validate = (validator, payload) => {
11
6
  const valid = validator(payload);
12
7
  if (!valid) {
13
8
  console.error(validator.errors);
@@ -16,7 +11,17 @@ const Validate = (name, payload) => {
16
11
  }
17
12
  };
18
13
 
19
- module.exports = {
20
- AddSchema,
21
- Validate
14
+ const AddSchema = (name, schema) => {
15
+ ajv.addSchema(schema, name);
16
+ return (payload) => {
17
+ const validator = ajv.getSchema(name)
18
+ _Validate(validator, payload)
19
+ }
20
+ };
21
+
22
+ const Validate = (name, payload) => {
23
+ const validator = ajv.getSchema(name)
24
+ _Validate(validator, payload);
22
25
  };
26
+
27
+ module.exports = { AddSchema, Validate };