badmfck-api-server 3.9.84 → 3.9.85
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.
@@ -31,30 +31,12 @@ class Validator {
|
|
31
31
|
for (let i in structure) {
|
32
32
|
if (i.startsWith("$__"))
|
33
33
|
continue;
|
34
|
-
let
|
35
|
-
let description = structure['$__' + i] || "";
|
34
|
+
let structureOptions = Validator.parseStructureOptions(i, structure);
|
36
35
|
let childs = undefined;
|
37
|
-
let optional = structure['$__' + i + "_optional"] || "";
|
38
|
-
let regex = structure['$__' + i + '_regex'] || undefined;
|
39
|
-
let min = structure['$__' + i + "_min"] || undefined;
|
40
|
-
let max = structure['$__' + i + "_max"] || undefined;
|
41
|
-
let values = structure['$__' + i + "_values"] || undefined;
|
42
|
-
if (optional === undefined)
|
43
|
-
optional = structure[i] === null || structure[i] === undefined;
|
44
|
-
if (type === "object" && Array.isArray(structure[i]))
|
45
|
-
type = "array";
|
46
36
|
if (typeof structure[i] === "object")
|
47
37
|
childs = this.documentStructure(structure[i]);
|
48
|
-
if (structure[i] === "@")
|
49
|
-
type = "email";
|
50
38
|
params[i] = {
|
51
|
-
|
52
|
-
description: description,
|
53
|
-
optional: optional,
|
54
|
-
regex: regex,
|
55
|
-
min: min,
|
56
|
-
max: max,
|
57
|
-
values: values,
|
39
|
+
...structureOptions,
|
58
40
|
childs: childs
|
59
41
|
};
|
60
42
|
}
|
@@ -80,6 +62,14 @@ class Validator {
|
|
80
62
|
}
|
81
63
|
if (s_options.max && isNaN(s_options.max))
|
82
64
|
s_options.max = undefined;
|
65
|
+
if (s_options && !s_options.type) {
|
66
|
+
let type = typeof structure[key];
|
67
|
+
if (type === "object" && Array.isArray(structure[key]))
|
68
|
+
type = "array";
|
69
|
+
if (structure[key] === "@")
|
70
|
+
type = "email";
|
71
|
+
s_options.type = type;
|
72
|
+
}
|
83
73
|
return {
|
84
74
|
...s_options,
|
85
75
|
optional: s_options.optional === undefined ? structure[k + 'optional'] ?? false : s_options.optional,
|