bguard 0.7.0 → 0.7.1
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/README.md +29 -11
- package/lib/asserts/array/index.d.mts +1 -1
- package/lib/asserts/array/index.d.ts +1 -1
- package/lib/asserts/array/index.js +4 -2
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +3 -1
- package/lib/asserts/bigint/index.d.mts +1 -1
- package/lib/asserts/bigint/index.d.ts +1 -1
- package/lib/asserts/bigint/index.js +5 -3
- package/lib/asserts/bigint/index.js.map +1 -1
- package/lib/asserts/bigint/index.mjs +4 -2
- package/lib/asserts/boolean/index.d.mts +1 -1
- package/lib/asserts/boolean/index.d.ts +1 -1
- package/lib/asserts/boolean/index.js +4 -2
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +3 -1
- package/lib/asserts/coerce/bigint.d.mts +32 -0
- package/lib/asserts/coerce/bigint.d.ts +32 -0
- package/lib/asserts/coerce/bigint.js +16 -0
- package/lib/asserts/coerce/bigint.js.map +1 -0
- package/lib/asserts/coerce/bigint.mjs +16 -0
- package/lib/asserts/coerce/bigint.mjs.map +1 -0
- package/lib/asserts/coerce/boolean.d.mts +35 -0
- package/lib/asserts/coerce/boolean.d.ts +35 -0
- package/lib/asserts/coerce/boolean.js +14 -0
- package/lib/asserts/coerce/boolean.js.map +1 -0
- package/lib/asserts/coerce/boolean.mjs +14 -0
- package/lib/asserts/coerce/boolean.mjs.map +1 -0
- package/lib/asserts/coerce/date.d.mts +32 -0
- package/lib/asserts/coerce/date.d.ts +32 -0
- package/lib/asserts/coerce/date.js +13 -0
- package/lib/asserts/coerce/date.js.map +1 -0
- package/lib/asserts/coerce/date.mjs +13 -0
- package/lib/asserts/coerce/date.mjs.map +1 -0
- package/lib/asserts/coerce/index.d.mts +25 -36
- package/lib/asserts/coerce/index.d.ts +25 -36
- package/lib/asserts/coerce/index.js +28 -8
- package/lib/asserts/coerce/index.js.map +1 -1
- package/lib/asserts/coerce/index.mjs +28 -8
- package/lib/asserts/coerce/number.d.mts +33 -0
- package/lib/asserts/coerce/number.d.ts +33 -0
- package/lib/asserts/coerce/number.js +16 -0
- package/lib/asserts/coerce/number.js.map +1 -0
- package/lib/asserts/coerce/number.mjs +16 -0
- package/lib/asserts/coerce/number.mjs.map +1 -0
- package/lib/asserts/coerce/string.d.mts +30 -0
- package/lib/asserts/coerce/string.d.ts +30 -0
- package/lib/asserts/coerce/string.js +17 -0
- package/lib/asserts/coerce/string.js.map +1 -0
- package/lib/asserts/coerce/string.mjs +17 -0
- package/lib/asserts/coerce/string.mjs.map +1 -0
- package/lib/asserts/date/index.d.mts +1 -1
- package/lib/asserts/date/index.d.ts +1 -1
- package/lib/asserts/date/index.js +4 -2
- package/lib/asserts/date/index.js.map +1 -1
- package/lib/asserts/date/index.mjs +3 -1
- package/lib/asserts/number/index.d.mts +1 -1
- package/lib/asserts/number/index.d.ts +1 -1
- package/lib/asserts/number/index.js +5 -3
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +4 -2
- package/lib/asserts/string/index.d.mts +1 -1
- package/lib/asserts/string/index.d.ts +1 -1
- package/lib/asserts/string/index.js +5 -3
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +4 -2
- package/lib/{chunk-GYLCPX6O.js → chunk-23R5R7PL.js} +3 -2
- package/lib/chunk-23R5R7PL.js.map +1 -0
- package/lib/{chunk-EVM26M2C.js → chunk-4PPMVVQY.js} +5 -4
- package/lib/chunk-4PPMVVQY.js.map +1 -0
- package/lib/chunk-56TWNROC.js +20 -0
- package/lib/chunk-56TWNROC.js.map +1 -0
- package/lib/{chunk-UWONIZJZ.mjs → chunk-5PXMSVTE.mjs} +6 -5
- package/lib/chunk-5PXMSVTE.mjs.map +1 -0
- package/lib/{chunk-B2R5S6OH.mjs → chunk-A2LPSUNQ.mjs} +3 -2
- package/lib/{chunk-B2R5S6OH.mjs.map → chunk-A2LPSUNQ.mjs.map} +1 -1
- package/lib/{chunk-EJCCIGXH.js → chunk-AGB5RWYD.js} +3 -2
- package/lib/chunk-AGB5RWYD.js.map +1 -0
- package/lib/{chunk-CJCIOMS7.mjs → chunk-DS2LUTTF.mjs} +6 -5
- package/lib/chunk-DS2LUTTF.mjs.map +1 -0
- package/lib/{chunk-UCHEFFWR.js → chunk-EI6TQG4L.js} +5 -4
- package/lib/chunk-EI6TQG4L.js.map +1 -0
- package/lib/chunk-ET2I4EXQ.mjs +18 -0
- package/lib/chunk-ET2I4EXQ.mjs.map +1 -0
- package/lib/chunk-FA3S35LQ.mjs +20 -0
- package/lib/chunk-FA3S35LQ.mjs.map +1 -0
- package/lib/{chunk-O646PJXY.mjs → chunk-FU5WAVRB.mjs} +3 -2
- package/lib/{chunk-O646PJXY.mjs.map → chunk-FU5WAVRB.mjs.map} +1 -1
- package/lib/chunk-HU5SDECP.js +29 -0
- package/lib/chunk-HU5SDECP.js.map +1 -0
- package/lib/{chunk-YJZXJKM4.mjs → chunk-J3EKIWPZ.mjs} +6 -5
- package/lib/chunk-J3EKIWPZ.mjs.map +1 -0
- package/lib/chunk-JCX2TB7E.js +13 -0
- package/lib/chunk-JCX2TB7E.js.map +1 -0
- package/lib/chunk-K7CDOU6F.js +13 -0
- package/lib/chunk-K7CDOU6F.js.map +1 -0
- package/lib/chunk-KALHMMEN.mjs +29 -0
- package/lib/chunk-KALHMMEN.mjs.map +1 -0
- package/lib/{chunk-5VZDHJKM.mjs → chunk-KGXWQ3XP.mjs} +3 -2
- package/lib/chunk-KGXWQ3XP.mjs.map +1 -0
- package/lib/chunk-MUXY6Q45.mjs +13 -0
- package/lib/chunk-MUXY6Q45.mjs.map +1 -0
- package/lib/chunk-SBNUNRI3.mjs +13 -0
- package/lib/chunk-SBNUNRI3.mjs.map +1 -0
- package/lib/chunk-TD3Y3IV3.js +13 -0
- package/lib/chunk-TD3Y3IV3.js.map +1 -0
- package/lib/chunk-UCY3HEYZ.mjs +13 -0
- package/lib/chunk-UCY3HEYZ.mjs.map +1 -0
- package/lib/{chunk-L7YFDMZU.js → chunk-WH7WJMFF.js} +5 -4
- package/lib/chunk-WH7WJMFF.js.map +1 -0
- package/lib/chunk-WLZZTIOV.js +18 -0
- package/lib/chunk-WLZZTIOV.js.map +1 -0
- package/lib/{chunk-DPXTSNEX.js → chunk-YPOEO3UF.js} +3 -2
- package/lib/chunk-YPOEO3UF.js.map +1 -0
- package/lib/index.d.mts +5 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +64 -44
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +78 -58
- package/package.json +12 -1
- package/lib/chunk-5VZDHJKM.mjs.map +0 -1
- package/lib/chunk-CJCIOMS7.mjs.map +0 -1
- package/lib/chunk-DPXTSNEX.js.map +0 -1
- package/lib/chunk-EJCCIGXH.js.map +0 -1
- package/lib/chunk-EVM26M2C.js.map +0 -1
- package/lib/chunk-GYLCPX6O.js.map +0 -1
- package/lib/chunk-KGNT5T35.mjs +0 -70
- package/lib/chunk-KGNT5T35.mjs.map +0 -1
- package/lib/chunk-L7YFDMZU.js.map +0 -1
- package/lib/chunk-TLLR2DXI.js +0 -70
- package/lib/chunk-TLLR2DXI.js.map +0 -1
- package/lib/chunk-UCHEFFWR.js.map +0 -1
- package/lib/chunk-UWONIZJZ.mjs.map +0 -1
- package/lib/chunk-YJZXJKM4.mjs.map +0 -1
|
@@ -1,52 +1,41 @@
|
|
|
1
|
+
import { DateSchema } from '../date/index.mjs';
|
|
2
|
+
import { BigIntSchema } from '../bigint/index.mjs';
|
|
3
|
+
import { BooleanSchema } from '../boolean/index.mjs';
|
|
4
|
+
import { NumberSchema } from '../number/index.mjs';
|
|
1
5
|
import { WithInput, WithBGuardType } from '../../commonTypes.mjs';
|
|
2
|
-
import {
|
|
6
|
+
import { StringSchema } from '../string/index.mjs';
|
|
7
|
+
export { coerceBigInt } from './bigint.mjs';
|
|
8
|
+
export { coerceBoolean } from './boolean.mjs';
|
|
9
|
+
export { coerceDate } from './date.mjs';
|
|
10
|
+
export { coerceNumber } from './number.mjs';
|
|
11
|
+
export { coerceString } from './string.mjs';
|
|
12
|
+
import '../../core.mjs';
|
|
3
13
|
import '../../InferType.mjs';
|
|
4
14
|
import '../../helpers/constants.mjs';
|
|
5
15
|
import '../../standardSchema.mjs';
|
|
6
16
|
|
|
7
17
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* Converts the received value before validating it, for input that does not arrive already typed —
|
|
15
|
-
* query strings, form data, environment variables.
|
|
18
|
+
* The coercing schemas gathered under one name, for when reaching for several of them reads better than
|
|
19
|
+
* five imports.
|
|
20
|
+
*
|
|
21
|
+
* Note that this object references all five, so a bundler has to keep all five wherever it is used —
|
|
22
|
+
* importing it for `coerce.number()` alone still pulls in the string, boolean, bigint and date schemas.
|
|
23
|
+
* Import the one you need from its own module when that matters:
|
|
16
24
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { coerceNumber } from 'bguard/coerce/number';
|
|
27
|
+
* ```
|
|
20
28
|
*
|
|
21
29
|
* @example
|
|
22
30
|
* const querySchema = object({ page: coerce.number().default(1), q: coerce.string() });
|
|
23
31
|
* parseOrFail(querySchema, { page: '3', q: 'shoes' }); // { page: 3, q: 'shoes' }
|
|
24
32
|
*/
|
|
25
33
|
declare const coerce: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* number.
|
|
32
|
-
*/
|
|
33
|
-
number: () => Coerced<WithBGuardType<CommonSchema, number>, unknown>;
|
|
34
|
-
/**
|
|
35
|
-
* Only the values that unambiguously mean a boolean are converted: the strings `'true'` and
|
|
36
|
-
* `'false'` in any case, and the numbers `1` and `0`. Everything else is left for validation to
|
|
37
|
-
* reject.
|
|
38
|
-
*
|
|
39
|
-
* Deliberately narrower than passing the value through `Boolean`, which would accept every input
|
|
40
|
-
* and quietly read `'false'` as `true`.
|
|
41
|
-
*/
|
|
42
|
-
boolean: () => Coerced<WithBGuardType<CommonSchema, boolean>, unknown>;
|
|
43
|
-
/** `BigInt` throws on a value it cannot read, so the original is kept for validation to reject. */
|
|
44
|
-
bigint: () => Coerced<WithBGuardType<CommonSchema, bigint>, unknown>;
|
|
45
|
-
/**
|
|
46
|
-
* Anything that is not already a Date is passed through `new Date`. An unreadable value becomes an
|
|
47
|
-
* invalid Date, which `date()` rejects.
|
|
48
|
-
*/
|
|
49
|
-
date: () => Coerced<WithBGuardType<CommonSchema, Date>, unknown>;
|
|
34
|
+
string: () => WithInput<WithBGuardType<StringSchema, string>, unknown>;
|
|
35
|
+
number: () => WithInput<WithBGuardType<NumberSchema, number>, unknown>;
|
|
36
|
+
boolean: () => WithInput<WithBGuardType<BooleanSchema, boolean>, unknown>;
|
|
37
|
+
bigint: () => WithInput<WithBGuardType<BigIntSchema, bigint>, unknown>;
|
|
38
|
+
date: () => WithInput<WithBGuardType<DateSchema, Date>, unknown>;
|
|
50
39
|
};
|
|
51
40
|
|
|
52
41
|
export { coerce };
|
|
@@ -1,52 +1,41 @@
|
|
|
1
|
+
import { DateSchema } from '../date/index.js';
|
|
2
|
+
import { BigIntSchema } from '../bigint/index.js';
|
|
3
|
+
import { BooleanSchema } from '../boolean/index.js';
|
|
4
|
+
import { NumberSchema } from '../number/index.js';
|
|
1
5
|
import { WithInput, WithBGuardType } from '../../commonTypes.js';
|
|
2
|
-
import {
|
|
6
|
+
import { StringSchema } from '../string/index.js';
|
|
7
|
+
export { coerceBigInt } from './bigint.js';
|
|
8
|
+
export { coerceBoolean } from './boolean.js';
|
|
9
|
+
export { coerceDate } from './date.js';
|
|
10
|
+
export { coerceNumber } from './number.js';
|
|
11
|
+
export { coerceString } from './string.js';
|
|
12
|
+
import '../../core.js';
|
|
3
13
|
import '../../InferType.js';
|
|
4
14
|
import '../../helpers/constants.js';
|
|
5
15
|
import '../../standardSchema.js';
|
|
6
16
|
|
|
7
17
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* Converts the received value before validating it, for input that does not arrive already typed —
|
|
15
|
-
* query strings, form data, environment variables.
|
|
18
|
+
* The coercing schemas gathered under one name, for when reaching for several of them reads better than
|
|
19
|
+
* five imports.
|
|
20
|
+
*
|
|
21
|
+
* Note that this object references all five, so a bundler has to keep all five wherever it is used —
|
|
22
|
+
* importing it for `coerce.number()` alone still pulls in the string, boolean, bigint and date schemas.
|
|
23
|
+
* Import the one you need from its own module when that matters:
|
|
16
24
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { coerceNumber } from 'bguard/coerce/number';
|
|
27
|
+
* ```
|
|
20
28
|
*
|
|
21
29
|
* @example
|
|
22
30
|
* const querySchema = object({ page: coerce.number().default(1), q: coerce.string() });
|
|
23
31
|
* parseOrFail(querySchema, { page: '3', q: 'shoes' }); // { page: 3, q: 'shoes' }
|
|
24
32
|
*/
|
|
25
33
|
declare const coerce: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* number.
|
|
32
|
-
*/
|
|
33
|
-
number: () => Coerced<WithBGuardType<CommonSchema, number>, unknown>;
|
|
34
|
-
/**
|
|
35
|
-
* Only the values that unambiguously mean a boolean are converted: the strings `'true'` and
|
|
36
|
-
* `'false'` in any case, and the numbers `1` and `0`. Everything else is left for validation to
|
|
37
|
-
* reject.
|
|
38
|
-
*
|
|
39
|
-
* Deliberately narrower than passing the value through `Boolean`, which would accept every input
|
|
40
|
-
* and quietly read `'false'` as `true`.
|
|
41
|
-
*/
|
|
42
|
-
boolean: () => Coerced<WithBGuardType<CommonSchema, boolean>, unknown>;
|
|
43
|
-
/** `BigInt` throws on a value it cannot read, so the original is kept for validation to reject. */
|
|
44
|
-
bigint: () => Coerced<WithBGuardType<CommonSchema, bigint>, unknown>;
|
|
45
|
-
/**
|
|
46
|
-
* Anything that is not already a Date is passed through `new Date`. An unreadable value becomes an
|
|
47
|
-
* invalid Date, which `date()` rejects.
|
|
48
|
-
*/
|
|
49
|
-
date: () => Coerced<WithBGuardType<CommonSchema, Date>, unknown>;
|
|
34
|
+
string: () => WithInput<WithBGuardType<StringSchema, string>, unknown>;
|
|
35
|
+
number: () => WithInput<WithBGuardType<NumberSchema, number>, unknown>;
|
|
36
|
+
boolean: () => WithInput<WithBGuardType<BooleanSchema, boolean>, unknown>;
|
|
37
|
+
bigint: () => WithInput<WithBGuardType<BigIntSchema, bigint>, unknown>;
|
|
38
|
+
date: () => WithInput<WithBGuardType<DateSchema, Date>, unknown>;
|
|
50
39
|
};
|
|
51
40
|
|
|
52
41
|
export { coerce };
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require('../../chunk-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
var _chunkHU5SDECPjs = require('../../chunk-HU5SDECP.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWLZZTIOVjs = require('../../chunk-WLZZTIOV.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk56TWNROCjs = require('../../chunk-56TWNROC.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkK7CDOU6Fjs = require('../../chunk-K7CDOU6F.js');
|
|
13
|
+
require('../../chunk-YPOEO3UF.js');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkJCX2TB7Ejs = require('../../chunk-JCX2TB7E.js');
|
|
17
|
+
require('../../chunk-4PPMVVQY.js');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunkTD3Y3IV3js = require('../../chunk-TD3Y3IV3.js');
|
|
21
|
+
require('../../chunk-EI6TQG4L.js');
|
|
22
|
+
require('../../chunk-WH7WJMFF.js');
|
|
9
23
|
require('../../chunk-OPA6AXSH.js');
|
|
10
|
-
require('../../chunk-
|
|
24
|
+
require('../../chunk-3D6TPN7F.js');
|
|
25
|
+
require('../../chunk-23R5R7PL.js');
|
|
11
26
|
require('../../chunk-EEKYR5IA.js');
|
|
12
27
|
require('../../chunk-FTHEF6SB.js');
|
|
13
28
|
require('../../chunk-6LUSV3SS.js');
|
|
@@ -17,5 +32,10 @@ require('../../chunk-LHEU4XAC.js');
|
|
|
17
32
|
require('../../chunk-ZWFSAKQK.js');
|
|
18
33
|
|
|
19
34
|
|
|
20
|
-
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.coerce = _chunkHU5SDECPjs.coerce; exports.coerceBigInt = _chunkWLZZTIOVjs.coerceBigInt; exports.coerceBoolean = _chunk56TWNROCjs.coerceBoolean; exports.coerceDate = _chunkK7CDOU6Fjs.coerceDate; exports.coerceNumber = _chunkJCX2TB7Ejs.coerceNumber; exports.coerceString = _chunkTD3Y3IV3js.coerceString;
|
|
21
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/coerce/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/coerce/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACA;AACA;AACA;AACA;AACA;AACF,qTAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/coerce/index.js"}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
coerce
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
3
|
+
} from "../../chunk-KALHMMEN.mjs";
|
|
4
|
+
import {
|
|
5
|
+
coerceBigInt
|
|
6
|
+
} from "../../chunk-ET2I4EXQ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
coerceBoolean
|
|
9
|
+
} from "../../chunk-FA3S35LQ.mjs";
|
|
10
|
+
import {
|
|
11
|
+
coerceDate
|
|
12
|
+
} from "../../chunk-MUXY6Q45.mjs";
|
|
13
|
+
import "../../chunk-FU5WAVRB.mjs";
|
|
14
|
+
import {
|
|
15
|
+
coerceNumber
|
|
16
|
+
} from "../../chunk-UCY3HEYZ.mjs";
|
|
17
|
+
import "../../chunk-DS2LUTTF.mjs";
|
|
18
|
+
import {
|
|
19
|
+
coerceString
|
|
20
|
+
} from "../../chunk-SBNUNRI3.mjs";
|
|
21
|
+
import "../../chunk-J3EKIWPZ.mjs";
|
|
22
|
+
import "../../chunk-5PXMSVTE.mjs";
|
|
9
23
|
import "../../chunk-YQP44G45.mjs";
|
|
10
|
-
import "../../chunk-
|
|
24
|
+
import "../../chunk-D42AL6CN.mjs";
|
|
25
|
+
import "../../chunk-KGXWQ3XP.mjs";
|
|
11
26
|
import "../../chunk-POPLWPM4.mjs";
|
|
12
27
|
import "../../chunk-IIL6D2UL.mjs";
|
|
13
28
|
import "../../chunk-LDZFOOWN.mjs";
|
|
@@ -16,6 +31,11 @@ import "../../chunk-YBVMP4EI.mjs";
|
|
|
16
31
|
import "../../chunk-C76DLZFD.mjs";
|
|
17
32
|
import "../../chunk-O2WD4JBG.mjs";
|
|
18
33
|
export {
|
|
19
|
-
coerce
|
|
34
|
+
coerce,
|
|
35
|
+
coerceBigInt,
|
|
36
|
+
coerceBoolean,
|
|
37
|
+
coerceDate,
|
|
38
|
+
coerceNumber,
|
|
39
|
+
coerceString
|
|
20
40
|
};
|
|
21
41
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { WithInput, WithBGuardType } from '../../commonTypes.mjs';
|
|
2
|
+
import { NumberSchema } from '../number/index.mjs';
|
|
3
|
+
import '../../core.mjs';
|
|
4
|
+
import '../../InferType.mjs';
|
|
5
|
+
import '../../helpers/constants.mjs';
|
|
6
|
+
import '../../standardSchema.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A coercing transform must never throw: it runs before validation, and throwing would replace a clear
|
|
10
|
+
* validation error with an unexplained failure. Anything it cannot convert is passed through unchanged
|
|
11
|
+
* so that validation reports the type problem itself.
|
|
12
|
+
*
|
|
13
|
+
* `null` is never coerced, so `nullable()` still decides whether it is allowed rather than it becoming
|
|
14
|
+
* the string `'null'` or the number `0`.
|
|
15
|
+
*
|
|
16
|
+
* The return type is inferred rather than written out. Naming it flattened the schema to
|
|
17
|
+
* `CommonSchema`, which silently dropped the methods only the concrete classes define — `equalTo`,
|
|
18
|
+
* `oneOfValues`, `onlyTrue`, `onlyFalse`.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @description Coerces the received value to a number before validating it. Anything that is not
|
|
22
|
+
* already a number is passed through `Number`.
|
|
23
|
+
*
|
|
24
|
+
* A value `Number` cannot read becomes `NaN`, which `number()` rejects, so `'abc'` fails validation
|
|
25
|
+
* rather than passing as a number.
|
|
26
|
+
*
|
|
27
|
+
* @returns A number schema that accepts `unknown` as its input type.
|
|
28
|
+
* @example
|
|
29
|
+
* parseOrFail(coerceNumber(), '42'); // 42
|
|
30
|
+
*/
|
|
31
|
+
declare const coerceNumber: () => WithInput<WithBGuardType<NumberSchema, number>, unknown>;
|
|
32
|
+
|
|
33
|
+
export { coerceNumber };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { WithInput, WithBGuardType } from '../../commonTypes.js';
|
|
2
|
+
import { NumberSchema } from '../number/index.js';
|
|
3
|
+
import '../../core.js';
|
|
4
|
+
import '../../InferType.js';
|
|
5
|
+
import '../../helpers/constants.js';
|
|
6
|
+
import '../../standardSchema.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A coercing transform must never throw: it runs before validation, and throwing would replace a clear
|
|
10
|
+
* validation error with an unexplained failure. Anything it cannot convert is passed through unchanged
|
|
11
|
+
* so that validation reports the type problem itself.
|
|
12
|
+
*
|
|
13
|
+
* `null` is never coerced, so `nullable()` still decides whether it is allowed rather than it becoming
|
|
14
|
+
* the string `'null'` or the number `0`.
|
|
15
|
+
*
|
|
16
|
+
* The return type is inferred rather than written out. Naming it flattened the schema to
|
|
17
|
+
* `CommonSchema`, which silently dropped the methods only the concrete classes define — `equalTo`,
|
|
18
|
+
* `oneOfValues`, `onlyTrue`, `onlyFalse`.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @description Coerces the received value to a number before validating it. Anything that is not
|
|
22
|
+
* already a number is passed through `Number`.
|
|
23
|
+
*
|
|
24
|
+
* A value `Number` cannot read becomes `NaN`, which `number()` rejects, so `'abc'` fails validation
|
|
25
|
+
* rather than passing as a number.
|
|
26
|
+
*
|
|
27
|
+
* @returns A number schema that accepts `unknown` as its input type.
|
|
28
|
+
* @example
|
|
29
|
+
* parseOrFail(coerceNumber(), '42'); // 42
|
|
30
|
+
*/
|
|
31
|
+
declare const coerceNumber: () => WithInput<WithBGuardType<NumberSchema, number>, unknown>;
|
|
32
|
+
|
|
33
|
+
export { coerceNumber };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkJCX2TB7Ejs = require('../../chunk-JCX2TB7E.js');
|
|
4
|
+
require('../../chunk-4PPMVVQY.js');
|
|
5
|
+
require('../../chunk-OPA6AXSH.js');
|
|
6
|
+
require('../../chunk-3D6TPN7F.js');
|
|
7
|
+
require('../../chunk-FTHEF6SB.js');
|
|
8
|
+
require('../../chunk-6LUSV3SS.js');
|
|
9
|
+
require('../../chunk-ZJGY6EOE.js');
|
|
10
|
+
require('../../chunk-VBTWYDEM.js');
|
|
11
|
+
require('../../chunk-LHEU4XAC.js');
|
|
12
|
+
require('../../chunk-ZWFSAKQK.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.coerceNumber = _chunkJCX2TB7Ejs.coerceNumber;
|
|
16
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/coerce/number.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/coerce/number.js"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
coerceNumber
|
|
3
|
+
} from "../../chunk-UCY3HEYZ.mjs";
|
|
4
|
+
import "../../chunk-DS2LUTTF.mjs";
|
|
5
|
+
import "../../chunk-YQP44G45.mjs";
|
|
6
|
+
import "../../chunk-D42AL6CN.mjs";
|
|
7
|
+
import "../../chunk-IIL6D2UL.mjs";
|
|
8
|
+
import "../../chunk-LDZFOOWN.mjs";
|
|
9
|
+
import "../../chunk-65X7NTUS.mjs";
|
|
10
|
+
import "../../chunk-YBVMP4EI.mjs";
|
|
11
|
+
import "../../chunk-C76DLZFD.mjs";
|
|
12
|
+
import "../../chunk-O2WD4JBG.mjs";
|
|
13
|
+
export {
|
|
14
|
+
coerceNumber
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=number.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WithInput, WithBGuardType } from '../../commonTypes.mjs';
|
|
2
|
+
import { StringSchema } from '../string/index.mjs';
|
|
3
|
+
import '../../core.mjs';
|
|
4
|
+
import '../../InferType.mjs';
|
|
5
|
+
import '../../helpers/constants.mjs';
|
|
6
|
+
import '../../standardSchema.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A coercing transform must never throw: it runs before validation, and throwing would replace a clear
|
|
10
|
+
* validation error with an unexplained failure. Anything it cannot convert is passed through unchanged
|
|
11
|
+
* so that validation reports the type problem itself.
|
|
12
|
+
*
|
|
13
|
+
* `null` is never coerced, so `nullable()` still decides whether it is allowed rather than it becoming
|
|
14
|
+
* the string `'null'` or the number `0`.
|
|
15
|
+
*
|
|
16
|
+
* The return type is inferred rather than written out. Naming it flattened the schema to
|
|
17
|
+
* `CommonSchema`, which silently dropped the methods only the concrete classes define — `equalTo`,
|
|
18
|
+
* `oneOfValues`, `onlyTrue`, `onlyFalse`.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @description Coerces the received value to a string before validating it. Anything that is not
|
|
22
|
+
* already a string is passed through `String`.
|
|
23
|
+
*
|
|
24
|
+
* @returns A string schema that accepts `unknown` as its input type.
|
|
25
|
+
* @example
|
|
26
|
+
* parseOrFail(coerceString(), 42); // '42'
|
|
27
|
+
*/
|
|
28
|
+
declare const coerceString: () => WithInput<WithBGuardType<StringSchema, string>, unknown>;
|
|
29
|
+
|
|
30
|
+
export { coerceString };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WithInput, WithBGuardType } from '../../commonTypes.js';
|
|
2
|
+
import { StringSchema } from '../string/index.js';
|
|
3
|
+
import '../../core.js';
|
|
4
|
+
import '../../InferType.js';
|
|
5
|
+
import '../../helpers/constants.js';
|
|
6
|
+
import '../../standardSchema.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A coercing transform must never throw: it runs before validation, and throwing would replace a clear
|
|
10
|
+
* validation error with an unexplained failure. Anything it cannot convert is passed through unchanged
|
|
11
|
+
* so that validation reports the type problem itself.
|
|
12
|
+
*
|
|
13
|
+
* `null` is never coerced, so `nullable()` still decides whether it is allowed rather than it becoming
|
|
14
|
+
* the string `'null'` or the number `0`.
|
|
15
|
+
*
|
|
16
|
+
* The return type is inferred rather than written out. Naming it flattened the schema to
|
|
17
|
+
* `CommonSchema`, which silently dropped the methods only the concrete classes define — `equalTo`,
|
|
18
|
+
* `oneOfValues`, `onlyTrue`, `onlyFalse`.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @description Coerces the received value to a string before validating it. Anything that is not
|
|
22
|
+
* already a string is passed through `String`.
|
|
23
|
+
*
|
|
24
|
+
* @returns A string schema that accepts `unknown` as its input type.
|
|
25
|
+
* @example
|
|
26
|
+
* parseOrFail(coerceString(), 42); // '42'
|
|
27
|
+
*/
|
|
28
|
+
declare const coerceString: () => WithInput<WithBGuardType<StringSchema, string>, unknown>;
|
|
29
|
+
|
|
30
|
+
export { coerceString };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkTD3Y3IV3js = require('../../chunk-TD3Y3IV3.js');
|
|
4
|
+
require('../../chunk-EI6TQG4L.js');
|
|
5
|
+
require('../../chunk-OPA6AXSH.js');
|
|
6
|
+
require('../../chunk-3D6TPN7F.js');
|
|
7
|
+
require('../../chunk-EEKYR5IA.js');
|
|
8
|
+
require('../../chunk-FTHEF6SB.js');
|
|
9
|
+
require('../../chunk-6LUSV3SS.js');
|
|
10
|
+
require('../../chunk-ZJGY6EOE.js');
|
|
11
|
+
require('../../chunk-VBTWYDEM.js');
|
|
12
|
+
require('../../chunk-LHEU4XAC.js');
|
|
13
|
+
require('../../chunk-ZWFSAKQK.js');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.coerceString = _chunkTD3Y3IV3js.coerceString;
|
|
17
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/coerce/string.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/coerce/string.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
coerceString
|
|
3
|
+
} from "../../chunk-SBNUNRI3.mjs";
|
|
4
|
+
import "../../chunk-J3EKIWPZ.mjs";
|
|
5
|
+
import "../../chunk-YQP44G45.mjs";
|
|
6
|
+
import "../../chunk-D42AL6CN.mjs";
|
|
7
|
+
import "../../chunk-POPLWPM4.mjs";
|
|
8
|
+
import "../../chunk-IIL6D2UL.mjs";
|
|
9
|
+
import "../../chunk-LDZFOOWN.mjs";
|
|
10
|
+
import "../../chunk-65X7NTUS.mjs";
|
|
11
|
+
import "../../chunk-YBVMP4EI.mjs";
|
|
12
|
+
import "../../chunk-C76DLZFD.mjs";
|
|
13
|
+
import "../../chunk-O2WD4JBG.mjs";
|
|
14
|
+
export {
|
|
15
|
+
coerceString
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=string.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
var _chunkYPOEO3UFjs = require('../../chunk-YPOEO3UF.js');
|
|
4
5
|
require('../../chunk-6LUSV3SS.js');
|
|
5
6
|
require('../../chunk-ZJGY6EOE.js');
|
|
6
7
|
require('../../chunk-VBTWYDEM.js');
|
|
@@ -8,5 +9,6 @@ require('../../chunk-LHEU4XAC.js');
|
|
|
8
9
|
require('../../chunk-ZWFSAKQK.js');
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
exports.DateSchema = _chunkYPOEO3UFjs.DateSchema; exports.date = _chunkYPOEO3UFjs.date;
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/date/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/date/index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACA;AACF,uFAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/date/index.js"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DateSchema,
|
|
2
3
|
date
|
|
3
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-FU5WAVRB.mjs";
|
|
4
5
|
import "../../chunk-LDZFOOWN.mjs";
|
|
5
6
|
import "../../chunk-65X7NTUS.mjs";
|
|
6
7
|
import "../../chunk-YBVMP4EI.mjs";
|
|
7
8
|
import "../../chunk-C76DLZFD.mjs";
|
|
8
9
|
import "../../chunk-O2WD4JBG.mjs";
|
|
9
10
|
export {
|
|
11
|
+
DateSchema,
|
|
10
12
|
date
|
|
11
13
|
};
|
|
12
14
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
|
|
4
|
+
var _chunk4PPMVVQYjs = require('../../chunk-4PPMVVQY.js');
|
|
5
5
|
require('../../chunk-OPA6AXSH.js');
|
|
6
|
+
require('../../chunk-3D6TPN7F.js');
|
|
6
7
|
require('../../chunk-FTHEF6SB.js');
|
|
7
8
|
require('../../chunk-6LUSV3SS.js');
|
|
8
9
|
require('../../chunk-ZJGY6EOE.js');
|
|
@@ -11,5 +12,6 @@ require('../../chunk-LHEU4XAC.js');
|
|
|
11
12
|
require('../../chunk-ZWFSAKQK.js');
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
exports.NumberSchema = _chunk4PPMVVQYjs.NumberSchema; exports.number = _chunk4PPMVVQYjs.number;
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/number/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/number/index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACA;AACF,+FAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/number/index.js"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
NumberSchema,
|
|
2
3
|
number
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-D42AL6CN.mjs";
|
|
4
|
+
} from "../../chunk-DS2LUTTF.mjs";
|
|
5
5
|
import "../../chunk-YQP44G45.mjs";
|
|
6
|
+
import "../../chunk-D42AL6CN.mjs";
|
|
6
7
|
import "../../chunk-IIL6D2UL.mjs";
|
|
7
8
|
import "../../chunk-LDZFOOWN.mjs";
|
|
8
9
|
import "../../chunk-65X7NTUS.mjs";
|
|
@@ -10,6 +11,7 @@ import "../../chunk-YBVMP4EI.mjs";
|
|
|
10
11
|
import "../../chunk-C76DLZFD.mjs";
|
|
11
12
|
import "../../chunk-O2WD4JBG.mjs";
|
|
12
13
|
export {
|
|
14
|
+
NumberSchema,
|
|
13
15
|
number
|
|
14
16
|
};
|
|
15
17
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
|
|
4
|
+
var _chunkEI6TQG4Ljs = require('../../chunk-EI6TQG4L.js');
|
|
5
5
|
require('../../chunk-OPA6AXSH.js');
|
|
6
|
+
require('../../chunk-3D6TPN7F.js');
|
|
6
7
|
require('../../chunk-EEKYR5IA.js');
|
|
7
8
|
require('../../chunk-FTHEF6SB.js');
|
|
8
9
|
require('../../chunk-6LUSV3SS.js');
|
|
@@ -12,5 +13,6 @@ require('../../chunk-LHEU4XAC.js');
|
|
|
12
13
|
require('../../chunk-ZWFSAKQK.js');
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
exports.StringSchema = _chunkEI6TQG4Ljs.StringSchema; exports.string = _chunkEI6TQG4Ljs.string;
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACA;AACF,+FAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/index.js"}
|