nox-validation 1.7.6 → 1.7.8
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/helpers.js +1 -1
- package/lib/validate.js +10 -6
- package/package.json +2 -2
package/lib/helpers.js
CHANGED
package/lib/validate.js
CHANGED
|
@@ -41,7 +41,6 @@ const typeChecks = {
|
|
|
41
41
|
}
|
|
42
42
|
return false;
|
|
43
43
|
},
|
|
44
|
-
|
|
45
44
|
[constants.types.DATE]: (val, data) => {
|
|
46
45
|
if (val instanceof Date && !isNaN(val)) return true;
|
|
47
46
|
if (typeof val === "string" && !isNaN(Date.parse(val))) {
|
|
@@ -86,7 +85,6 @@ const typeChecks = {
|
|
|
86
85
|
}
|
|
87
86
|
return false;
|
|
88
87
|
},
|
|
89
|
-
|
|
90
88
|
[constants.types.BOOLEAN]: (val, data) => {
|
|
91
89
|
if (typeof val === "boolean") return true;
|
|
92
90
|
if (typeof val === "string") {
|
|
@@ -101,10 +99,16 @@ const typeChecks = {
|
|
|
101
99
|
return false;
|
|
102
100
|
},
|
|
103
101
|
[constants.types.NUMBER]: (val, data) => {
|
|
104
|
-
if (typeof val === "number" &&
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
if (typeof val === "number" && Number.isFinite(val)) return true;
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
typeof val === "string" &&
|
|
106
|
+
val.trim() !== "" &&
|
|
107
|
+
/^[+-]?\d+(\.\d+)?$/.test(val)
|
|
108
|
+
) {
|
|
109
|
+
const num = Number(val);
|
|
110
|
+
if (data?.key && data?.updateValue) {
|
|
111
|
+
data.updateValue(data.key, num);
|
|
108
112
|
}
|
|
109
113
|
return true;
|
|
110
114
|
}
|
package/package.json
CHANGED