@awsless/validate 0.0.2 → 0.0.3
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 +4 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -99,15 +99,16 @@ var bigfloat = () => {
|
|
|
99
99
|
};
|
|
100
100
|
var positive = (struct2) => {
|
|
101
101
|
const expected = `Expected a positive ${struct2.type}`;
|
|
102
|
-
const
|
|
102
|
+
const ZERO = new import_big_float.BigFloat(0);
|
|
103
103
|
return (0, import_superstruct.refine)(struct2, "positive", (value) => {
|
|
104
|
-
return (0, import_big_float.gt)(value,
|
|
104
|
+
return (0, import_big_float.gt)(value, ZERO) || `${expected} but received '${value}'`;
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
107
|
var precision = (struct2, decimals) => {
|
|
108
108
|
const expected = `Expected a ${struct2.type}`;
|
|
109
109
|
return (0, import_superstruct.refine)(struct2, "precision", (value) => {
|
|
110
|
-
|
|
110
|
+
const big = new import_big_float.BigFloat(value);
|
|
111
|
+
return -big.exponent <= decimals || `${expected} with ${decimals} decimals`;
|
|
111
112
|
});
|
|
112
113
|
};
|
|
113
114
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { BigFloat } from '@awsless/big-float';
|
|
|
4
4
|
import { UUID } from 'crypto';
|
|
5
5
|
|
|
6
6
|
declare const bigfloat: () => Struct<BigFloat, null>;
|
|
7
|
-
declare const positive: <T extends BigFloat, S extends unknown>(struct: Struct<T, S>) => Struct<T, S>;
|
|
8
|
-
declare const precision: <T extends BigFloat, S extends unknown>(struct: Struct<T, S>, decimals: number) => Struct<T, S>;
|
|
7
|
+
declare const positive: <T extends number | BigFloat, S extends unknown>(struct: Struct<T, S>) => Struct<T, S>;
|
|
8
|
+
declare const precision: <T extends number | BigFloat, S extends unknown>(struct: Struct<T, S>, decimals: number) => Struct<T, S>;
|
|
9
9
|
|
|
10
10
|
declare const date: () => Struct<Date, null>;
|
|
11
11
|
|
package/dist/index.js
CHANGED
|
@@ -16,15 +16,16 @@ var bigfloat = () => {
|
|
|
16
16
|
};
|
|
17
17
|
var positive = (struct2) => {
|
|
18
18
|
const expected = `Expected a positive ${struct2.type}`;
|
|
19
|
-
const
|
|
19
|
+
const ZERO = new BigFloat(0);
|
|
20
20
|
return refine(struct2, "positive", (value) => {
|
|
21
|
-
return gt(value,
|
|
21
|
+
return gt(value, ZERO) || `${expected} but received '${value}'`;
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
24
|
var precision = (struct2, decimals) => {
|
|
25
25
|
const expected = `Expected a ${struct2.type}`;
|
|
26
26
|
return refine(struct2, "precision", (value) => {
|
|
27
|
-
|
|
27
|
+
const big = new BigFloat(value);
|
|
28
|
+
return -big.exponent <= decimals || `${expected} with ${decimals} decimals`;
|
|
28
29
|
});
|
|
29
30
|
};
|
|
30
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/validate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@awsless/big-float": "^0.0.
|
|
30
|
+
"@awsless/big-float": "^0.0.2"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"superstruct": "^1.0.3"
|