ismx-nexo-node-app 0.3.56 → 0.3.57

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.
@@ -75,7 +75,10 @@ class BusinessErrors {
75
75
  }
76
76
  isType(key, value, type, assertion) {
77
77
  try {
78
- if (!assertion(value))
78
+ let val = assertion(value);
79
+ if (type === 'number' && (Number.isNaN(val) || !Number.isFinite(val)))
80
+ throw new Error();
81
+ if (type === 'date' && (!(val instanceof Date) || isNaN(val.getTime())))
79
82
  throw new Error();
80
83
  }
81
84
  catch (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.3.56",
3
+ "version": "0.3.57",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -71,8 +71,11 @@ export default class BusinessErrors {
71
71
  }
72
72
 
73
73
  isType<T>(key: string, value: string, type:string, assertion: (value:string)=>T): T {
74
- try { if (!assertion(value)) throw new Error(); }
75
- catch { this.except("0021", key, type) }
74
+ try {
75
+ let val = assertion(value);
76
+ if (type === 'number' && (Number.isNaN(val) || !Number.isFinite(val))) throw new Error();
77
+ if (type === 'date' && (!(val instanceof Date) || isNaN(val.getTime()))) throw new Error()
78
+ } catch { this.except("0021", key, type) }
76
79
  return assertion(value);
77
80
  }
78
81