@lucania/schema 1.0.4 → 1.0.6
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/build/index.js +8 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -35,7 +35,14 @@
|
|
|
35
35
|
},
|
|
36
36
|
string: {
|
|
37
37
|
boolean: (value) => value === "false" ? false : Boolean(value),
|
|
38
|
-
number: (value) =>
|
|
38
|
+
number: (value) => {
|
|
39
|
+
const numberValue = parseFloat(value);
|
|
40
|
+
if (Number.isNaN(numberValue)) {
|
|
41
|
+
Schema.assert(value.length !== 0, `Failed to convert empty string to number.`);
|
|
42
|
+
throw new Schema.Error(`Failed to convert "${value}" to number.`);
|
|
43
|
+
}
|
|
44
|
+
return numberValue;
|
|
45
|
+
},
|
|
39
46
|
bigint: (value) => BigInt(value),
|
|
40
47
|
any: (value) => JSON.parse(value),
|
|
41
48
|
Date: (value) => new Date(value)
|