badmfck-api-server 4.1.13 → 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.13";
101
+ version = "4.1.15";
102
102
  options;
103
103
  monitor = null;
104
104
  started = new Date();
@@ -331,6 +331,10 @@ class APIService extends BaseService_1.BaseService {
331
331
  respond({ error: { ...DefaultErrors_1.default.DB_ERROR, details: e.message } });
332
332
  return;
333
333
  }
334
+ if (DefaultErrors_1.ErrorUtils.isError(e)) {
335
+ respond({ error: e });
336
+ return;
337
+ }
334
338
  respond({ error: { code: 10002, message: "Internal server error!", stack: stack, details: details }, data: null, httpStatus: 500 });
335
339
  return;
336
340
  }
@@ -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.13",
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",