badmfck-api-server 4.1.14 → 4.1.16
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.
|
@@ -263,9 +263,13 @@ class Validator {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
if (typeof structure[i] === "string" && structureOptions.regex) {
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
const val = object[i];
|
|
267
|
+
const isEmpty = val === "" || val === null || val === undefined;
|
|
268
|
+
if (!(structureOptions.optional && isEmpty)) {
|
|
269
|
+
const reg = new RegExp(structureOptions.regex);
|
|
270
|
+
if (reg.test(val) === false)
|
|
271
|
+
errors.push("wrong value for field '" + parentPath + i + "', false mask for: >" + val + "<");
|
|
272
|
+
}
|
|
269
273
|
}
|
|
270
274
|
if (typeof structure[i] === "string" && (structure[i] === "@" || structure[i] === "email")) {
|
|
271
275
|
const value = object[i].toString().toLowerCase().trim();
|