not-node 6.2.5 → 6.2.6
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
package/src/form/form.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const validator = require("validator");
|
|
2
|
+
|
|
1
3
|
const FormFabric = require("./fabric");
|
|
2
4
|
|
|
3
5
|
const { createSchemaFromFields } = require("../fields");
|
|
@@ -186,6 +188,7 @@ class Form {
|
|
|
186
188
|
return () => {
|
|
187
189
|
//should be sync function
|
|
188
190
|
return {
|
|
191
|
+
validator,
|
|
189
192
|
env: true, //some env variables for validators
|
|
190
193
|
};
|
|
191
194
|
};
|
|
@@ -368,9 +371,9 @@ class Form {
|
|
|
368
371
|
}
|
|
369
372
|
if (
|
|
370
373
|
req?.notRouteData?.rule?.fields &&
|
|
371
|
-
Array.isArray(req.notRouteData.rule.fields
|
|
374
|
+
Array.isArray(req.notRouteData.rule.fields)
|
|
372
375
|
) {
|
|
373
|
-
return req.notRouteData.rule.fields;
|
|
376
|
+
return req.notRouteData.rule.fields.flat(2);
|
|
374
377
|
}
|
|
375
378
|
return [];
|
|
376
379
|
}
|
|
@@ -2,7 +2,7 @@ const path = require("path");
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const { tryFile, objHas } = require("../../common");
|
|
4
4
|
const Fields = require("../../fields");
|
|
5
|
-
|
|
5
|
+
const { log } = require("not-log")(module, "register//fields");
|
|
6
6
|
module.exports = class notModuleRegistratorFields {
|
|
7
7
|
static openFile = require;
|
|
8
8
|
static fieldsManager = Fields;
|
|
@@ -39,9 +39,14 @@ module.exports = class notModuleRegistratorFields {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
registerField({ nModule, name, field, fromPath }) {
|
|
42
|
-
this.extendByFrontValidators({
|
|
42
|
+
const fieldValidatorsCount = this.extendByFrontValidators({
|
|
43
|
+
name,
|
|
44
|
+
field,
|
|
45
|
+
fromPath: path.dirname(fromPath),
|
|
46
|
+
});
|
|
43
47
|
nModule.setField(name, field);
|
|
44
|
-
|
|
48
|
+
const MODULE_NAME = nModule.getName();
|
|
49
|
+
log(`${MODULE_NAME}//${name} with ${fieldValidatorsCount} validators`);
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
/**
|
|
@@ -54,7 +59,7 @@ module.exports = class notModuleRegistratorFields {
|
|
|
54
59
|
//load validators
|
|
55
60
|
const validatorName = path.join(fromPath, "validators", name + ".js");
|
|
56
61
|
if (!tryFile(validatorName)) {
|
|
57
|
-
return;
|
|
62
|
+
return 0;
|
|
58
63
|
}
|
|
59
64
|
const validators = notModuleRegistratorFields.openFile(validatorName);
|
|
60
65
|
//inject into field.model
|
|
@@ -62,6 +67,7 @@ module.exports = class notModuleRegistratorFields {
|
|
|
62
67
|
field.model.validate = [];
|
|
63
68
|
}
|
|
64
69
|
field.model.validate.push(...validators);
|
|
70
|
+
return validators.length;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
/**
|
package/src/model/proto.js
CHANGED
|
@@ -22,7 +22,16 @@ module.exports = class ModelFabricate {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
if (targetModule.schemaOptions) {
|
|
25
|
-
options
|
|
25
|
+
options = {
|
|
26
|
+
...options,
|
|
27
|
+
schemaOptions: targetModule.schemaOptions,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (targetModule.options) {
|
|
31
|
+
options = {
|
|
32
|
+
...options,
|
|
33
|
+
...targetModule.options,
|
|
34
|
+
};
|
|
26
35
|
}
|
|
27
36
|
return options;
|
|
28
37
|
}
|
|
@@ -64,6 +73,11 @@ module.exports = class ModelFabricate {
|
|
|
64
73
|
|
|
65
74
|
static enrichByFields(targetModule, options) {
|
|
66
75
|
if (targetModule.enrich) {
|
|
76
|
+
const model_name = targetModule.thisModelName;
|
|
77
|
+
console.log(
|
|
78
|
+
`MODEL: ${model_name}`,
|
|
79
|
+
JSON.stringify(options, null, 4)
|
|
80
|
+
);
|
|
67
81
|
if (targetModule.enrich.validators) {
|
|
68
82
|
targetModule.thisSchema = enrich.byFieldsValidators(
|
|
69
83
|
targetModule.thisSchema,
|