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.
@@ -95,7 +95,7 @@ async function Initializer(services) {
95
95
  exports.Initializer = Initializer;
96
96
  class APIService extends BaseService_1.BaseService {
97
97
  static nextLogID = 0;
98
- version = "3.2.6";
98
+ version = "3.2.7";
99
99
  options;
100
100
  monitor = null;
101
101
  monitorIndexFile;
@@ -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].includes("regex:")) {
124
- const regex = structure[i].substring(6);
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "3.2.6",
3
+ "version": "3.2.7",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",