badmfck-api-server 4.1.14 → 4.1.15

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.
@@ -98,7 +98,7 @@ async function Initializer(services) {
98
98
  }
99
99
  exports.Initializer = Initializer;
100
100
  class APIService extends BaseService_1.BaseService {
101
- version = "4.1.14";
101
+ version = "4.1.15";
102
102
  options;
103
103
  monitor = null;
104
104
  started = new Date();
@@ -263,9 +263,13 @@ class Validator {
263
263
  }
264
264
  }
265
265
  if (typeof structure[i] === "string" && structureOptions.regex) {
266
- const reg = new RegExp(structureOptions.regex);
267
- if (reg.test(object[i]) === false)
268
- errors.push("wrong value for field '" + parentPath + i + "', false mask for: >" + object[i] + "<");
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "4.1.14",
3
+ "version": "4.1.15",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",