not-node 5.1.20 → 5.1.21

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/package.json +1 -1
  2. package/src/form/form.js +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "5.1.20",
3
+ "version": "5.1.21",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/form/form.js CHANGED
@@ -2,7 +2,7 @@ const FormFabric = require("./fabric");
2
2
 
3
3
  const { createSchemaFromFields } = require("../fields");
4
4
 
5
- const { objHas } = require("../common");
5
+ const { objHas, isFunc } = require("../common");
6
6
 
7
7
  const ValidationBuilder = require("not-validation").Builder;
8
8
  const ValidationSession = require("not-validation").Session;
@@ -36,7 +36,7 @@ class Form {
36
36
  fromParams,
37
37
  };
38
38
 
39
- constructor({ FIELDS, FORM_NAME, app, EXTRACTORS = [] }) {
39
+ constructor({ FIELDS, FORM_NAME, app, EXTRACTORS = {} }) {
40
40
  this.#FORM_NAME = FORM_NAME;
41
41
  this.#PROTO_FIELDS = FIELDS;
42
42
  this.#createValidationSchema(app);
@@ -218,15 +218,19 @@ class Form {
218
218
  return FormFabric;
219
219
  }
220
220
 
221
- #addExtractors(extractors) {
222
- this.#EXTRACTORS = { ...this.#EXTRACTORS, ...extractors };
221
+ #addExtractors(extractors = {}) {
222
+ if (extractors) {
223
+ this.#EXTRACTORS = { ...this.#EXTRACTORS, ...extractors };
224
+ }
223
225
  }
224
226
 
225
227
  extractByInstructions(req, instructions) {
226
228
  const results = {};
227
229
  for (let fieldName of instructions) {
228
230
  const instruction = instructions[fieldName];
229
- results[fieldName] = instruction(req, fieldName);
231
+ if (isFunc(instruction)) {
232
+ results[fieldName] = instruction(req, fieldName);
233
+ }
230
234
  }
231
235
  return results;
232
236
  }