not-node 4.0.18 → 4.0.19
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
|
@@ -36,14 +36,30 @@ module.exports = class notModuleRegistratorFields{
|
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
registerField({name, field, fieldsImportRules}){
|
|
39
|
+
registerField({name, field, fieldsImportRules, fromPath}){
|
|
40
|
+
this.extendByFrontValidators({name, field, fromPath});
|
|
40
41
|
notModuleRegistratorFields.fieldsManager.registerField(
|
|
41
|
-
name,
|
|
42
|
-
field,
|
|
42
|
+
name, //field name
|
|
43
|
+
field, //field description
|
|
43
44
|
fieldsImportRules //global import rules
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
**/
|
|
51
|
+
extendByFrontValidators({name, field, fromPath}){
|
|
52
|
+
if(!(field && objHas(field, 'model'))){ return; }
|
|
53
|
+
//load validators
|
|
54
|
+
const validatorName = path.join(fromPath, 'validators', name + '.js');
|
|
55
|
+
if(!tryFile(validatorName)){return;}
|
|
56
|
+
const validators = notModuleRegistratorFields.openFile(validatorName);
|
|
57
|
+
//inject into field.model
|
|
58
|
+
if(!objHas(field.model, 'validate')){
|
|
59
|
+
field.model.validate = [];
|
|
60
|
+
}
|
|
61
|
+
field.model.validate.push(...validators);
|
|
62
|
+
}
|
|
47
63
|
|
|
48
64
|
|
|
49
65
|
/**
|
|
@@ -72,11 +88,10 @@ module.exports = class notModuleRegistratorFields{
|
|
|
72
88
|
this.registerField({
|
|
73
89
|
name: parts.name, //fields name
|
|
74
90
|
field: fields, //field description
|
|
75
|
-
fieldsImportRules: nModule.fieldsImportRules //global import rules
|
|
91
|
+
fieldsImportRules: nModule.fieldsImportRules, //global import rules
|
|
92
|
+
fromPath
|
|
76
93
|
});
|
|
77
94
|
}
|
|
78
95
|
}
|
|
79
96
|
|
|
80
|
-
|
|
81
|
-
|
|
82
97
|
};
|