@awsless/validate 0.0.3 → 0.0.4
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/dist/index.cjs +7 -1
- package/dist/index.js +12 -6
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -88,7 +88,13 @@ var bigfloat = () => {
|
|
|
88
88
|
const base = (0, import_superstruct.define)("bigfloat", (value) => {
|
|
89
89
|
return value instanceof import_big_float.BigFloat || "Invalid number";
|
|
90
90
|
});
|
|
91
|
-
|
|
91
|
+
const bigFloatLike = (0, import_superstruct.coerce)(base, (0, import_superstruct.object)({
|
|
92
|
+
exponent: (0, import_superstruct.number)(),
|
|
93
|
+
coefficient: (0, import_superstruct.bigint)()
|
|
94
|
+
}), (value) => {
|
|
95
|
+
return new import_big_float.BigFloat(value);
|
|
96
|
+
});
|
|
97
|
+
return (0, import_superstruct.coerce)(bigFloatLike, (0, import_superstruct.union)([(0, import_superstruct.string)(), (0, import_superstruct.number)()]), (value) => {
|
|
92
98
|
if (typeof value === "string" && value !== "" || typeof value === "number") {
|
|
93
99
|
if (!isNaN(Number(value))) {
|
|
94
100
|
return new import_big_float.BigFloat(value);
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
// src/types/bigfloat.ts
|
|
2
|
-
import { coerce, define, number, string, union, refine } from "superstruct";
|
|
2
|
+
import { coerce, define, number, string, union, refine, object, bigint } from "superstruct";
|
|
3
3
|
import { BigFloat, gt } from "@awsless/big-float";
|
|
4
4
|
var bigfloat = () => {
|
|
5
5
|
const base = define("bigfloat", (value) => {
|
|
6
6
|
return value instanceof BigFloat || "Invalid number";
|
|
7
7
|
});
|
|
8
|
-
|
|
8
|
+
const bigFloatLike = coerce(base, object({
|
|
9
|
+
exponent: number(),
|
|
10
|
+
coefficient: bigint()
|
|
11
|
+
}), (value) => {
|
|
12
|
+
return new BigFloat(value);
|
|
13
|
+
});
|
|
14
|
+
return coerce(bigFloatLike, union([string(), number()]), (value) => {
|
|
9
15
|
if (typeof value === "string" && value !== "" || typeof value === "number") {
|
|
10
16
|
if (!isNaN(Number(value))) {
|
|
11
17
|
return new BigFloat(value);
|
|
@@ -95,7 +101,7 @@ import {
|
|
|
95
101
|
refine as refine3,
|
|
96
102
|
any,
|
|
97
103
|
array,
|
|
98
|
-
bigint,
|
|
104
|
+
bigint as bigint2,
|
|
99
105
|
boolean,
|
|
100
106
|
enums,
|
|
101
107
|
func,
|
|
@@ -107,7 +113,7 @@ import {
|
|
|
107
113
|
never,
|
|
108
114
|
nullable,
|
|
109
115
|
number as number2,
|
|
110
|
-
object,
|
|
116
|
+
object as object2,
|
|
111
117
|
optional,
|
|
112
118
|
record,
|
|
113
119
|
regexp,
|
|
@@ -141,7 +147,7 @@ export {
|
|
|
141
147
|
assert,
|
|
142
148
|
assign,
|
|
143
149
|
bigfloat,
|
|
144
|
-
bigint,
|
|
150
|
+
bigint2 as bigint,
|
|
145
151
|
boolean,
|
|
146
152
|
coerce5 as coerce,
|
|
147
153
|
create,
|
|
@@ -169,7 +175,7 @@ export {
|
|
|
169
175
|
nonempty,
|
|
170
176
|
nullable,
|
|
171
177
|
number2 as number,
|
|
172
|
-
object,
|
|
178
|
+
object2 as object,
|
|
173
179
|
omit,
|
|
174
180
|
optional,
|
|
175
181
|
partial,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/validate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@awsless/big-float": "^0.0.
|
|
27
|
+
"@awsless/big-float": "^0.0.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@awsless/big-float": "^0.0.
|
|
30
|
+
"@awsless/big-float": "^0.0.3"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"superstruct": "^1.0.3"
|