@reldens/utils 0.33.0 → 0.35.0
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.
- package/lib/schema-validator.js +8 -0
- package/lib/shortcuts.js +8 -3
- package/package.json +1 -1
package/lib/schema-validator.js
CHANGED
|
@@ -66,6 +66,14 @@ class SchemaValidator
|
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
|
+
case 'number':
|
|
70
|
+
if(!sc.isInt(obj)){
|
|
71
|
+
if(!sc.isFloat(obj)){
|
|
72
|
+
Logger.debug('Object is not a number.', objectKey, obj, schema);
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
69
77
|
case 'int':
|
|
70
78
|
if(!sc.isInt(obj)){
|
|
71
79
|
Logger.debug('Object is not an integer.', objectKey, obj, schema);
|
package/lib/shortcuts.js
CHANGED
|
@@ -44,7 +44,7 @@ class Shortcuts
|
|
|
44
44
|
if(!this.isArray(dataArray)){
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
|
-
return -1
|
|
47
|
+
return -1 !== dataArray.indexOf(value);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
isFunction(callback)
|
|
@@ -62,9 +62,14 @@ class Shortcuts
|
|
|
62
62
|
return 'string' === typeof value;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
isNumber(value)
|
|
66
|
+
{
|
|
67
|
+
return 'number' === typeof value;
|
|
68
|
+
}
|
|
69
|
+
|
|
65
70
|
isInt(value)
|
|
66
71
|
{
|
|
67
|
-
if(
|
|
72
|
+
if(!this.isNumber(value)){
|
|
68
73
|
return false;
|
|
69
74
|
}
|
|
70
75
|
return Number.isInteger(value);
|
|
@@ -72,7 +77,7 @@ class Shortcuts
|
|
|
72
77
|
|
|
73
78
|
isFloat(value)
|
|
74
79
|
{
|
|
75
|
-
if(
|
|
80
|
+
if(!this.isNumber(value)){
|
|
76
81
|
return false;
|
|
77
82
|
}
|
|
78
83
|
return Number(value) === value && 0 !== value % 1;
|