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.
Files changed (134) hide show
  1. package/README.md +29 -11
  2. package/lib/asserts/array/index.d.mts +1 -1
  3. package/lib/asserts/array/index.d.ts +1 -1
  4. package/lib/asserts/array/index.js +4 -2
  5. package/lib/asserts/array/index.js.map +1 -1
  6. package/lib/asserts/array/index.mjs +3 -1
  7. package/lib/asserts/bigint/index.d.mts +1 -1
  8. package/lib/asserts/bigint/index.d.ts +1 -1
  9. package/lib/asserts/bigint/index.js +5 -3
  10. package/lib/asserts/bigint/index.js.map +1 -1
  11. package/lib/asserts/bigint/index.mjs +4 -2
  12. package/lib/asserts/boolean/index.d.mts +1 -1
  13. package/lib/asserts/boolean/index.d.ts +1 -1
  14. package/lib/asserts/boolean/index.js +4 -2
  15. package/lib/asserts/boolean/index.js.map +1 -1
  16. package/lib/asserts/boolean/index.mjs +3 -1
  17. package/lib/asserts/coerce/bigint.d.mts +32 -0
  18. package/lib/asserts/coerce/bigint.d.ts +32 -0
  19. package/lib/asserts/coerce/bigint.js +16 -0
  20. package/lib/asserts/coerce/bigint.js.map +1 -0
  21. package/lib/asserts/coerce/bigint.mjs +16 -0
  22. package/lib/asserts/coerce/bigint.mjs.map +1 -0
  23. package/lib/asserts/coerce/boolean.d.mts +35 -0
  24. package/lib/asserts/coerce/boolean.d.ts +35 -0
  25. package/lib/asserts/coerce/boolean.js +14 -0
  26. package/lib/asserts/coerce/boolean.js.map +1 -0
  27. package/lib/asserts/coerce/boolean.mjs +14 -0
  28. package/lib/asserts/coerce/boolean.mjs.map +1 -0
  29. package/lib/asserts/coerce/date.d.mts +32 -0
  30. package/lib/asserts/coerce/date.d.ts +32 -0
  31. package/lib/asserts/coerce/date.js +13 -0
  32. package/lib/asserts/coerce/date.js.map +1 -0
  33. package/lib/asserts/coerce/date.mjs +13 -0
  34. package/lib/asserts/coerce/date.mjs.map +1 -0
  35. package/lib/asserts/coerce/index.d.mts +25 -36
  36. package/lib/asserts/coerce/index.d.ts +25 -36
  37. package/lib/asserts/coerce/index.js +28 -8
  38. package/lib/asserts/coerce/index.js.map +1 -1
  39. package/lib/asserts/coerce/index.mjs +28 -8
  40. package/lib/asserts/coerce/number.d.mts +33 -0
  41. package/lib/asserts/coerce/number.d.ts +33 -0
  42. package/lib/asserts/coerce/number.js +16 -0
  43. package/lib/asserts/coerce/number.js.map +1 -0
  44. package/lib/asserts/coerce/number.mjs +16 -0
  45. package/lib/asserts/coerce/number.mjs.map +1 -0
  46. package/lib/asserts/coerce/string.d.mts +30 -0
  47. package/lib/asserts/coerce/string.d.ts +30 -0
  48. package/lib/asserts/coerce/string.js +17 -0
  49. package/lib/asserts/coerce/string.js.map +1 -0
  50. package/lib/asserts/coerce/string.mjs +17 -0
  51. package/lib/asserts/coerce/string.mjs.map +1 -0
  52. package/lib/asserts/date/index.d.mts +1 -1
  53. package/lib/asserts/date/index.d.ts +1 -1
  54. package/lib/asserts/date/index.js +4 -2
  55. package/lib/asserts/date/index.js.map +1 -1
  56. package/lib/asserts/date/index.mjs +3 -1
  57. package/lib/asserts/number/index.d.mts +1 -1
  58. package/lib/asserts/number/index.d.ts +1 -1
  59. package/lib/asserts/number/index.js +5 -3
  60. package/lib/asserts/number/index.js.map +1 -1
  61. package/lib/asserts/number/index.mjs +4 -2
  62. package/lib/asserts/string/index.d.mts +1 -1
  63. package/lib/asserts/string/index.d.ts +1 -1
  64. package/lib/asserts/string/index.js +5 -3
  65. package/lib/asserts/string/index.js.map +1 -1
  66. package/lib/asserts/string/index.mjs +4 -2
  67. package/lib/{chunk-GYLCPX6O.js → chunk-23R5R7PL.js} +3 -2
  68. package/lib/chunk-23R5R7PL.js.map +1 -0
  69. package/lib/{chunk-EVM26M2C.js → chunk-4PPMVVQY.js} +5 -4
  70. package/lib/chunk-4PPMVVQY.js.map +1 -0
  71. package/lib/chunk-56TWNROC.js +20 -0
  72. package/lib/chunk-56TWNROC.js.map +1 -0
  73. package/lib/{chunk-UWONIZJZ.mjs → chunk-5PXMSVTE.mjs} +6 -5
  74. package/lib/chunk-5PXMSVTE.mjs.map +1 -0
  75. package/lib/{chunk-B2R5S6OH.mjs → chunk-A2LPSUNQ.mjs} +3 -2
  76. package/lib/{chunk-B2R5S6OH.mjs.map → chunk-A2LPSUNQ.mjs.map} +1 -1
  77. package/lib/{chunk-EJCCIGXH.js → chunk-AGB5RWYD.js} +3 -2
  78. package/lib/chunk-AGB5RWYD.js.map +1 -0
  79. package/lib/{chunk-CJCIOMS7.mjs → chunk-DS2LUTTF.mjs} +6 -5
  80. package/lib/chunk-DS2LUTTF.mjs.map +1 -0
  81. package/lib/{chunk-UCHEFFWR.js → chunk-EI6TQG4L.js} +5 -4
  82. package/lib/chunk-EI6TQG4L.js.map +1 -0
  83. package/lib/chunk-ET2I4EXQ.mjs +18 -0
  84. package/lib/chunk-ET2I4EXQ.mjs.map +1 -0
  85. package/lib/chunk-FA3S35LQ.mjs +20 -0
  86. package/lib/chunk-FA3S35LQ.mjs.map +1 -0
  87. package/lib/{chunk-O646PJXY.mjs → chunk-FU5WAVRB.mjs} +3 -2
  88. package/lib/{chunk-O646PJXY.mjs.map → chunk-FU5WAVRB.mjs.map} +1 -1
  89. package/lib/chunk-HU5SDECP.js +29 -0
  90. package/lib/chunk-HU5SDECP.js.map +1 -0
  91. package/lib/{chunk-YJZXJKM4.mjs → chunk-J3EKIWPZ.mjs} +6 -5
  92. package/lib/chunk-J3EKIWPZ.mjs.map +1 -0
  93. package/lib/chunk-JCX2TB7E.js +13 -0
  94. package/lib/chunk-JCX2TB7E.js.map +1 -0
  95. package/lib/chunk-K7CDOU6F.js +13 -0
  96. package/lib/chunk-K7CDOU6F.js.map +1 -0
  97. package/lib/chunk-KALHMMEN.mjs +29 -0
  98. package/lib/chunk-KALHMMEN.mjs.map +1 -0
  99. package/lib/{chunk-5VZDHJKM.mjs → chunk-KGXWQ3XP.mjs} +3 -2
  100. package/lib/chunk-KGXWQ3XP.mjs.map +1 -0
  101. package/lib/chunk-MUXY6Q45.mjs +13 -0
  102. package/lib/chunk-MUXY6Q45.mjs.map +1 -0
  103. package/lib/chunk-SBNUNRI3.mjs +13 -0
  104. package/lib/chunk-SBNUNRI3.mjs.map +1 -0
  105. package/lib/chunk-TD3Y3IV3.js +13 -0
  106. package/lib/chunk-TD3Y3IV3.js.map +1 -0
  107. package/lib/chunk-UCY3HEYZ.mjs +13 -0
  108. package/lib/chunk-UCY3HEYZ.mjs.map +1 -0
  109. package/lib/{chunk-L7YFDMZU.js → chunk-WH7WJMFF.js} +5 -4
  110. package/lib/chunk-WH7WJMFF.js.map +1 -0
  111. package/lib/chunk-WLZZTIOV.js +18 -0
  112. package/lib/chunk-WLZZTIOV.js.map +1 -0
  113. package/lib/{chunk-DPXTSNEX.js → chunk-YPOEO3UF.js} +3 -2
  114. package/lib/chunk-YPOEO3UF.js.map +1 -0
  115. package/lib/index.d.mts +5 -0
  116. package/lib/index.d.ts +5 -0
  117. package/lib/index.js +64 -44
  118. package/lib/index.js.map +1 -1
  119. package/lib/index.mjs +78 -58
  120. package/package.json +12 -1
  121. package/lib/chunk-5VZDHJKM.mjs.map +0 -1
  122. package/lib/chunk-CJCIOMS7.mjs.map +0 -1
  123. package/lib/chunk-DPXTSNEX.js.map +0 -1
  124. package/lib/chunk-EJCCIGXH.js.map +0 -1
  125. package/lib/chunk-EVM26M2C.js.map +0 -1
  126. package/lib/chunk-GYLCPX6O.js.map +0 -1
  127. package/lib/chunk-KGNT5T35.mjs +0 -70
  128. package/lib/chunk-KGNT5T35.mjs.map +0 -1
  129. package/lib/chunk-L7YFDMZU.js.map +0 -1
  130. package/lib/chunk-TLLR2DXI.js +0 -70
  131. package/lib/chunk-TLLR2DXI.js.map +0 -1
  132. package/lib/chunk-UCHEFFWR.js.map +0 -1
  133. package/lib/chunk-UWONIZJZ.mjs.map +0 -1
  134. 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 { CommonSchema } from '../../core.mjs';
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
- * A coercing transform must never throw: it runs before validation, and throwing would replace a
9
- * clear validation error with an unexplained failure. Anything it cannot convert is passed through
10
- * unchanged so that validation reports the type problem itself.
11
- */
12
- type Coerced<S, In> = WithInput<S, In>;
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
- * Each of these accepts `unknown` and reports that in its inferred input type, while the output type
18
- * is unchanged. `null` is left alone, so `nullable()` still decides whether it is allowed rather than
19
- * being turned into the string `'null'` or the number `0`.
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
- /** Anything that is not already a string is passed through `String`. */
27
- string: () => Coerced<WithBGuardType<CommonSchema, string>, unknown>;
28
- /**
29
- * Anything that is not already a number is passed through `Number`. A value `Number` cannot read
30
- * becomes `NaN`, which `number()` rejects, so `'abc'` fails validation rather than passing as a
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 { CommonSchema } from '../../core.js';
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
- * A coercing transform must never throw: it runs before validation, and throwing would replace a
9
- * clear validation error with an unexplained failure. Anything it cannot convert is passed through
10
- * unchanged so that validation reports the type problem itself.
11
- */
12
- type Coerced<S, In> = WithInput<S, In>;
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
- * Each of these accepts `unknown` and reports that in its inferred input type, while the output type
18
- * is unchanged. `null` is left alone, so `nullable()` still decides whether it is allowed rather than
19
- * being turned into the string `'null'` or the number `0`.
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
- /** Anything that is not already a string is passed through `String`. */
27
- string: () => Coerced<WithBGuardType<CommonSchema, string>, unknown>;
28
- /**
29
- * Anything that is not already a number is passed through `Number`. A value `Number` cannot read
30
- * becomes `NaN`, which `number()` rejects, so `'abc'` fails validation rather than passing as a
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 _chunkTLLR2DXIjs = require('../../chunk-TLLR2DXI.js');
4
- require('../../chunk-UCHEFFWR.js');
5
- require('../../chunk-EVM26M2C.js');
6
- require('../../chunk-DPXTSNEX.js');
7
- require('../../chunk-L7YFDMZU.js');
8
- require('../../chunk-3D6TPN7F.js');
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-GYLCPX6O.js');
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
- exports.coerce = _chunkTLLR2DXIjs.coerce;
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,yCAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/coerce/index.js"}
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-KGNT5T35.mjs";
4
- import "../../chunk-YJZXJKM4.mjs";
5
- import "../../chunk-CJCIOMS7.mjs";
6
- import "../../chunk-O646PJXY.mjs";
7
- import "../../chunk-UWONIZJZ.mjs";
8
- import "../../chunk-D42AL6CN.mjs";
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-5VZDHJKM.mjs";
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":[]}
@@ -20,4 +20,4 @@ declare class DateSchema extends CommonSchema {
20
20
  constructor(ctx: ValidatorContext);
21
21
  }
22
22
 
23
- export { date };
23
+ export { DateSchema, date };
@@ -20,4 +20,4 @@ declare class DateSchema extends CommonSchema {
20
20
  constructor(ctx: ValidatorContext);
21
21
  }
22
22
 
23
- export { date };
23
+ export { DateSchema, date };
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDPXTSNEXjs = require('../../chunk-DPXTSNEX.js');
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
- exports.date = _chunkDPXTSNEXjs.date;
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,qCAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/date/index.js"}
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-O646PJXY.mjs";
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
@@ -42,4 +42,4 @@ declare class NumberSchema extends CommonSchema {
42
42
  oneOfValues<Y extends number>(expectedValue: Y[]): WithBGuardType<this, Y>;
43
43
  }
44
44
 
45
- export { number };
45
+ export { NumberSchema, number };
@@ -42,4 +42,4 @@ declare class NumberSchema extends CommonSchema {
42
42
  oneOfValues<Y extends number>(expectedValue: Y[]): WithBGuardType<this, Y>;
43
43
  }
44
44
 
45
- export { number };
45
+ export { NumberSchema, number };
@@ -1,8 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkEVM26M2Cjs = require('../../chunk-EVM26M2C.js');
4
- require('../../chunk-3D6TPN7F.js');
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
- exports.number = _chunkEVM26M2Cjs.number;
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,yCAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/number/index.js"}
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-CJCIOMS7.mjs";
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
@@ -47,4 +47,4 @@ declare class StringSchema extends CommonSchema {
47
47
  private limitGuard;
48
48
  }
49
49
 
50
- export { string };
50
+ export { StringSchema, string };
@@ -47,4 +47,4 @@ declare class StringSchema extends CommonSchema {
47
47
  private limitGuard;
48
48
  }
49
49
 
50
- export { string };
50
+ export { StringSchema, string };
@@ -1,8 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUCHEFFWRjs = require('../../chunk-UCHEFFWR.js');
4
- require('../../chunk-3D6TPN7F.js');
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
- exports.string = _chunkUCHEFFWRjs.string;
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,yCAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/index.js"}
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"}