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
package/README.md CHANGED
@@ -722,29 +722,47 @@ message that came from `address.street`. `treeifyErrors` keeps the full structur
722
722
  For input that does not arrive already typed — query strings, form data, environment variables.
723
723
 
724
724
  ```typeScript
725
- import { coerce } from 'bguard/coerce';
725
+ import { coerceNumber } from 'bguard/coerce/number';
726
+ import { coerceBoolean } from 'bguard/coerce/boolean';
726
727
  import { object } from 'bguard/object';
727
728
  import { parseOrFail } from 'bguard';
728
729
 
729
730
  const querySchema = object({
730
- page: coerce.number().default(1),
731
- limit: coerce.number(),
732
- active: coerce.boolean(),
731
+ page: coerceNumber().default(1),
732
+ limit: coerceNumber(),
733
+ active: coerceBoolean(),
733
734
  });
734
735
 
735
736
  parseOrFail(querySchema, { limit: '20', active: 'true' });
736
737
  // { page: 1, limit: 20, active: true }
737
738
  ```
738
739
 
739
- `coerce.string()`, `coerce.number()`, `coerce.boolean()`, `coerce.bigint()` and `coerce.date()` convert
740
- the value before validating it. Anything a helper cannot convert is left alone, so validation reports
741
- the type problem rather than the conversion silently succeeding: `coerce.number()` on `'abc'` fails,
742
- because `Number('abc')` is `NaN` and `number()` rejects that.
740
+ `coerceString`, `coerceNumber`, `coerceBoolean`, `coerceBigInt` and `coerceDate` convert the value
741
+ before validating it. Each lives in its own module `bguard/coerce/number` and so on — like every other
742
+ assertion in the package.
743
+
744
+ They are also gathered on a `coerce` object for when several read better together:
745
+
746
+ ```typeScript
747
+ import { coerce } from 'bguard/coerce';
748
+ import { object } from 'bguard/object';
749
+
750
+ object({ page: coerce.number(), q: coerce.string() });
751
+ ```
752
+
753
+ > **Notice:** that object references all five, so a bundler has to keep all five wherever it is used.
754
+ > Reaching for `coerce.number()` alone still pulls in the string, boolean, bigint and date schemas —
755
+ > measured at 2033 bytes against 87 for importing `coerceNumber` from its own module. Import the one you
756
+ > need when bundle size matters.
757
+
758
+ Anything a helper cannot convert is left alone, so validation reports the type problem rather than the conversion silently
759
+ succeeding: `coerceNumber()` on `'abc'` fails, because `Number('abc')` is `NaN` and `number()` rejects
760
+ that.
743
761
 
744
762
  `null` is never coerced, so `nullable()` still decides whether it is allowed instead of it becoming the
745
763
  string `'null'` or the number `0`.
746
764
 
747
- > **Notice:** `coerce.boolean()` only converts what unambiguously means a boolean — the strings
765
+ > **Notice:** `coerceBoolean()` only converts what unambiguously means a boolean — the strings
748
766
  > `'true'` and `'false'` in any case, and the numbers `1` and `0`. Everything else is rejected. This is
749
767
  > deliberately narrower than passing the value through `Boolean`, which would accept every input and
750
768
  > read `'false'` as `true`.
@@ -755,12 +773,12 @@ string `'null'` or the number `0`.
755
773
  *accepts*. The two differ wherever a schema converts or supplies something:
756
774
 
757
775
  ```typeScript
758
- import { coerce } from 'bguard/coerce';
776
+ import { coerceNumber } from 'bguard/coerce/number';
759
777
  import { object } from 'bguard/object';
760
778
  import { string } from 'bguard/string';
761
779
  import type { InferType, InferInput } from 'bguard/InferType';
762
780
 
763
- const schema = object({ page: coerce.number().default(1), q: string() });
781
+ const schema = object({ page: coerceNumber().default(1), q: string() });
764
782
 
765
783
  type Output = InferType<typeof schema>; // { page: number; q: string }
766
784
  type Input = InferInput<typeof schema>; // { q: string; page?: unknown }
@@ -23,4 +23,4 @@ declare class ArraySchema extends CommonSchema {
23
23
  private validateArrayEntry;
24
24
  }
25
25
 
26
- export { array };
26
+ export { ArraySchema, array };
@@ -23,4 +23,4 @@ declare class ArraySchema extends CommonSchema {
23
23
  private validateArrayEntry;
24
24
  }
25
25
 
26
- export { array };
26
+ export { ArraySchema, array };
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkEJCCIGXHjs = require('../../chunk-EJCCIGXH.js');
3
+
4
+ var _chunkAGB5RWYDjs = require('../../chunk-AGB5RWYD.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.array = _chunkEJCCIGXHjs.array;
12
+
13
+ exports.ArraySchema = _chunkAGB5RWYDjs.ArraySchema; exports.array = _chunkAGB5RWYDjs.array;
12
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/array/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,uCAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/array/index.js"}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/array/index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACA;AACF,2FAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/array/index.js"}
@@ -1,12 +1,14 @@
1
1
  import {
2
+ ArraySchema,
2
3
  array
3
- } from "../../chunk-B2R5S6OH.mjs";
4
+ } from "../../chunk-A2LPSUNQ.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
+ ArraySchema,
10
12
  array
11
13
  };
12
14
  //# sourceMappingURL=index.mjs.map
@@ -48,4 +48,4 @@ declare class BigIntSchema extends CommonSchema {
48
48
  private limitGuard;
49
49
  }
50
50
 
51
- export { bigint };
51
+ export { BigIntSchema, bigint };
@@ -48,4 +48,4 @@ declare class BigIntSchema extends CommonSchema {
48
48
  private limitGuard;
49
49
  }
50
50
 
51
- export { bigint };
51
+ export { BigIntSchema, bigint };
@@ -1,8 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkL7YFDMZUjs = require('../../chunk-L7YFDMZU.js');
4
- require('../../chunk-3D6TPN7F.js');
3
+
4
+ var _chunkWH7WJMFFjs = require('../../chunk-WH7WJMFF.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.bigint = _chunkL7YFDMZUjs.bigint;
15
+
16
+ exports.BigIntSchema = _chunkWH7WJMFFjs.BigIntSchema; exports.bigint = _chunkWH7WJMFFjs.bigint;
15
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/bigint/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/bigint/index.js"}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/bigint/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/bigint/index.js"}
@@ -1,8 +1,9 @@
1
1
  import {
2
+ BigIntSchema,
2
3
  bigint
3
- } from "../../chunk-UWONIZJZ.mjs";
4
- import "../../chunk-D42AL6CN.mjs";
4
+ } from "../../chunk-5PXMSVTE.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
+ BigIntSchema,
13
15
  bigint
14
16
  };
15
17
  //# sourceMappingURL=index.mjs.map
@@ -45,4 +45,4 @@ declare class BooleanSchema extends CommonSchema {
45
45
  onlyFalse(): WithBGuardType<this, false>;
46
46
  }
47
47
 
48
- export { boolean };
48
+ export { BooleanSchema, boolean };
@@ -45,4 +45,4 @@ declare class BooleanSchema extends CommonSchema {
45
45
  onlyFalse(): WithBGuardType<this, false>;
46
46
  }
47
47
 
48
- export { boolean };
48
+ export { BooleanSchema, boolean };
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkGYLCPX6Ojs = require('../../chunk-GYLCPX6O.js');
3
+
4
+ var _chunk23R5R7PLjs = require('../../chunk-23R5R7PL.js');
4
5
  require('../../chunk-FTHEF6SB.js');
5
6
  require('../../chunk-6LUSV3SS.js');
6
7
  require('../../chunk-ZJGY6EOE.js');
@@ -9,5 +10,6 @@ require('../../chunk-LHEU4XAC.js');
9
10
  require('../../chunk-ZWFSAKQK.js');
10
11
 
11
12
 
12
- exports.boolean = _chunkGYLCPX6Ojs.boolean;
13
+
14
+ exports.BooleanSchema = _chunk23R5R7PLjs.BooleanSchema; exports.boolean = _chunk23R5R7PLjs.boolean;
13
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/boolean/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,2CAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/boolean/index.js"}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/boolean/index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACA;AACF,mGAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/boolean/index.js"}
@@ -1,6 +1,7 @@
1
1
  import {
2
+ BooleanSchema,
2
3
  boolean
3
- } from "../../chunk-5VZDHJKM.mjs";
4
+ } from "../../chunk-KGXWQ3XP.mjs";
4
5
  import "../../chunk-IIL6D2UL.mjs";
5
6
  import "../../chunk-LDZFOOWN.mjs";
6
7
  import "../../chunk-65X7NTUS.mjs";
@@ -8,6 +9,7 @@ import "../../chunk-YBVMP4EI.mjs";
8
9
  import "../../chunk-C76DLZFD.mjs";
9
10
  import "../../chunk-O2WD4JBG.mjs";
10
11
  export {
12
+ BooleanSchema,
11
13
  boolean
12
14
  };
13
15
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,32 @@
1
+ import { WithInput, WithBGuardType } from '../../commonTypes.mjs';
2
+ import { BigIntSchema } from '../bigint/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 bigint before validating it.
22
+ *
23
+ * `BigInt` throws on a value it cannot read, so the original is kept for validation to reject rather
24
+ * than the error escaping.
25
+ *
26
+ * @returns A bigint schema that accepts `unknown` as its input type.
27
+ * @example
28
+ * parseOrFail(coerceBigInt(), '42'); // 42n
29
+ */
30
+ declare const coerceBigInt: () => WithInput<WithBGuardType<BigIntSchema, bigint>, unknown>;
31
+
32
+ export { coerceBigInt };
@@ -0,0 +1,32 @@
1
+ import { WithInput, WithBGuardType } from '../../commonTypes.js';
2
+ import { BigIntSchema } from '../bigint/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 bigint before validating it.
22
+ *
23
+ * `BigInt` throws on a value it cannot read, so the original is kept for validation to reject rather
24
+ * than the error escaping.
25
+ *
26
+ * @returns A bigint schema that accepts `unknown` as its input type.
27
+ * @example
28
+ * parseOrFail(coerceBigInt(), '42'); // 42n
29
+ */
30
+ declare const coerceBigInt: () => WithInput<WithBGuardType<BigIntSchema, bigint>, unknown>;
31
+
32
+ export { coerceBigInt };
@@ -0,0 +1,16 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkWLZZTIOVjs = require('../../chunk-WLZZTIOV.js');
4
+ require('../../chunk-WH7WJMFF.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.coerceBigInt = _chunkWLZZTIOVjs.coerceBigInt;
16
+ //# sourceMappingURL=bigint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/coerce/bigint.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/bigint.js"}
@@ -0,0 +1,16 @@
1
+ import {
2
+ coerceBigInt
3
+ } from "../../chunk-ET2I4EXQ.mjs";
4
+ import "../../chunk-5PXMSVTE.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
+ coerceBigInt
15
+ };
16
+ //# sourceMappingURL=bigint.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,35 @@
1
+ import { WithInput, WithBGuardType } from '../../commonTypes.mjs';
2
+ import { BooleanSchema } from '../boolean/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 boolean before validating it.
22
+ *
23
+ * Only the values that unambiguously mean a boolean are converted: the strings `'true'` and `'false'`
24
+ * in any case, and the numbers `1` and `0`. Everything else is left for validation to reject.
25
+ *
26
+ * Deliberately narrower than passing the value through `Boolean`, which would accept every input and
27
+ * quietly read `'false'` as `true`.
28
+ *
29
+ * @returns A boolean schema that accepts `unknown` as its input type.
30
+ * @example
31
+ * parseOrFail(coerceBoolean(), 'false'); // false
32
+ */
33
+ declare const coerceBoolean: () => WithInput<WithBGuardType<BooleanSchema, boolean>, unknown>;
34
+
35
+ export { coerceBoolean };
@@ -0,0 +1,35 @@
1
+ import { WithInput, WithBGuardType } from '../../commonTypes.js';
2
+ import { BooleanSchema } from '../boolean/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 boolean before validating it.
22
+ *
23
+ * Only the values that unambiguously mean a boolean are converted: the strings `'true'` and `'false'`
24
+ * in any case, and the numbers `1` and `0`. Everything else is left for validation to reject.
25
+ *
26
+ * Deliberately narrower than passing the value through `Boolean`, which would accept every input and
27
+ * quietly read `'false'` as `true`.
28
+ *
29
+ * @returns A boolean schema that accepts `unknown` as its input type.
30
+ * @example
31
+ * parseOrFail(coerceBoolean(), 'false'); // false
32
+ */
33
+ declare const coerceBoolean: () => WithInput<WithBGuardType<BooleanSchema, boolean>, unknown>;
34
+
35
+ export { coerceBoolean };
@@ -0,0 +1,14 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk56TWNROCjs = require('../../chunk-56TWNROC.js');
4
+ require('../../chunk-23R5R7PL.js');
5
+ require('../../chunk-FTHEF6SB.js');
6
+ require('../../chunk-6LUSV3SS.js');
7
+ require('../../chunk-ZJGY6EOE.js');
8
+ require('../../chunk-VBTWYDEM.js');
9
+ require('../../chunk-LHEU4XAC.js');
10
+ require('../../chunk-ZWFSAKQK.js');
11
+
12
+
13
+ exports.coerceBoolean = _chunk56TWNROCjs.coerceBoolean;
14
+ //# sourceMappingURL=boolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/coerce/boolean.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,uDAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/coerce/boolean.js"}
@@ -0,0 +1,14 @@
1
+ import {
2
+ coerceBoolean
3
+ } from "../../chunk-FA3S35LQ.mjs";
4
+ import "../../chunk-KGXWQ3XP.mjs";
5
+ import "../../chunk-IIL6D2UL.mjs";
6
+ import "../../chunk-LDZFOOWN.mjs";
7
+ import "../../chunk-65X7NTUS.mjs";
8
+ import "../../chunk-YBVMP4EI.mjs";
9
+ import "../../chunk-C76DLZFD.mjs";
10
+ import "../../chunk-O2WD4JBG.mjs";
11
+ export {
12
+ coerceBoolean
13
+ };
14
+ //# sourceMappingURL=boolean.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,32 @@
1
+ import { WithInput, WithBGuardType } from '../../commonTypes.mjs';
2
+ import { DateSchema } from '../date/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 Date before validating it. Anything that is not already
22
+ * a Date is passed through `new Date`.
23
+ *
24
+ * An unreadable value becomes an invalid Date, which `date()` rejects.
25
+ *
26
+ * @returns A date schema that accepts `unknown` as its input type.
27
+ * @example
28
+ * parseOrFail(coerceDate(), '2024-01-01'); // Date
29
+ */
30
+ declare const coerceDate: () => WithInput<WithBGuardType<DateSchema, Date>, unknown>;
31
+
32
+ export { coerceDate };
@@ -0,0 +1,32 @@
1
+ import { WithInput, WithBGuardType } from '../../commonTypes.js';
2
+ import { DateSchema } from '../date/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 Date before validating it. Anything that is not already
22
+ * a Date is passed through `new Date`.
23
+ *
24
+ * An unreadable value becomes an invalid Date, which `date()` rejects.
25
+ *
26
+ * @returns A date schema that accepts `unknown` as its input type.
27
+ * @example
28
+ * parseOrFail(coerceDate(), '2024-01-01'); // Date
29
+ */
30
+ declare const coerceDate: () => WithInput<WithBGuardType<DateSchema, Date>, unknown>;
31
+
32
+ export { coerceDate };
@@ -0,0 +1,13 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkK7CDOU6Fjs = require('../../chunk-K7CDOU6F.js');
4
+ require('../../chunk-YPOEO3UF.js');
5
+ require('../../chunk-6LUSV3SS.js');
6
+ require('../../chunk-ZJGY6EOE.js');
7
+ require('../../chunk-VBTWYDEM.js');
8
+ require('../../chunk-LHEU4XAC.js');
9
+ require('../../chunk-ZWFSAKQK.js');
10
+
11
+
12
+ exports.coerceDate = _chunkK7CDOU6Fjs.coerceDate;
13
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/coerce/date.js"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,iDAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/coerce/date.js"}
@@ -0,0 +1,13 @@
1
+ import {
2
+ coerceDate
3
+ } from "../../chunk-MUXY6Q45.mjs";
4
+ import "../../chunk-FU5WAVRB.mjs";
5
+ import "../../chunk-LDZFOOWN.mjs";
6
+ import "../../chunk-65X7NTUS.mjs";
7
+ import "../../chunk-YBVMP4EI.mjs";
8
+ import "../../chunk-C76DLZFD.mjs";
9
+ import "../../chunk-O2WD4JBG.mjs";
10
+ export {
11
+ coerceDate
12
+ };
13
+ //# sourceMappingURL=date.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}