badmfck-api-server 4.0.81 → 4.0.82

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.
@@ -157,6 +157,8 @@ class Validator {
157
157
  let num = parseInt(object[i]);
158
158
  if (object[i].includes("."))
159
159
  num = parseFloat(object[i]);
160
+ if (isNaN(num))
161
+ num = structureOptions.default !== undefined ? structureOptions.default : NaN;
160
162
  if (isNaN(num))
161
163
  errors.push("wrong value for field '" + parentPath + i + "', expected number got " + object[i]);
162
164
  else
@@ -209,6 +211,10 @@ class Validator {
209
211
  structureOptions.values = structure['$__' + i + "_values"];
210
212
  if (Array.isArray(structureOptions.values) && structureOptions.values.length) {
211
213
  if (!structureOptions.values.includes(object[i])) {
214
+ if (structureOptions.default && structureOptions.values.includes(structureOptions.default)) {
215
+ object[i] = structureOptions.default;
216
+ continue;
217
+ }
212
218
  let caseValue = null;
213
219
  for (let i of structureOptions.values) {
214
220
  if (i === null || i === undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "4.0.81",
3
+ "version": "4.0.82",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",