badmfck-api-server 3.2.6 → 3.2.7
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.
@@ -120,8 +120,8 @@ class Validator {
|
|
120
120
|
errors.push("wrong value for field '" + i + "', expected " + expected.join(", ") + " got: " + value);
|
121
121
|
}
|
122
122
|
}
|
123
|
-
if (typeof structure[i] === "string" && structure[i]
|
124
|
-
const regex = structure[i]
|
123
|
+
if (typeof structure[i] === "string" && structure["$__regex_" + i]) {
|
124
|
+
const regex = structure["$__regex_" + i];
|
125
125
|
const reg = new RegExp(regex);
|
126
126
|
if (reg.test(object[i]) === false)
|
127
127
|
errors.push("wrong value for field '" + i + "', false mask for: " + object[i]);
|
@@ -154,6 +154,16 @@ class Validator {
|
|
154
154
|
}
|
155
155
|
}
|
156
156
|
}
|
157
|
+
if (typeof structure[i] === "number" && structure["$__min_" + i]) {
|
158
|
+
const min = structure["$__min_" + i];
|
159
|
+
if (object[i] < min)
|
160
|
+
errors.push("value for field '" + i + "' is too small, expected more than " + min + " got: " + object[i]);
|
161
|
+
}
|
162
|
+
if (typeof structure[i] === "number" && structure["$__max_" + i]) {
|
163
|
+
const max = structure["$__max_" + i];
|
164
|
+
if (object[i] > max)
|
165
|
+
errors.push("value for field '" + i + "' is too big, expected less than " + max + " got: " + object[i]);
|
166
|
+
}
|
157
167
|
foundKeys.push(i);
|
158
168
|
}
|
159
169
|
if (errors.length > 0)
|