bguard 0.0.4 → 0.0.6

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 (239) hide show
  1. package/lib/{CommonSchema-DeTBsQhn.d.mts → CommonSchema-BIe85W_A.d.mts} +3 -1
  2. package/lib/{CommonSchema-DeTBsQhn.d.ts → CommonSchema-BIe85W_A.d.ts} +3 -1
  3. package/lib/InferType.d.mts +18 -0
  4. package/lib/InferType.d.ts +18 -0
  5. package/lib/InferType.js +1 -0
  6. package/lib/InferType.js.map +1 -0
  7. package/lib/InferType.mjs +1 -0
  8. package/lib/InferType.mjs.map +1 -0
  9. package/lib/asserts/array/index.d.mts +18 -2
  10. package/lib/asserts/array/index.d.ts +18 -2
  11. package/lib/asserts/array/index.js +7 -86
  12. package/lib/asserts/array/index.js.map +1 -1
  13. package/lib/asserts/array/index.mjs +7 -59
  14. package/lib/asserts/array/index.mjs.map +1 -1
  15. package/lib/asserts/boolean/index.d.mts +16 -2
  16. package/lib/asserts/boolean/index.d.ts +16 -2
  17. package/lib/asserts/boolean/index.js +7 -114
  18. package/lib/asserts/boolean/index.js.map +1 -1
  19. package/lib/asserts/boolean/index.mjs +7 -87
  20. package/lib/asserts/boolean/index.mjs.map +1 -1
  21. package/lib/asserts/common/equalTo.d.mts +1 -1
  22. package/lib/asserts/common/equalTo.d.ts +1 -1
  23. package/lib/asserts/common/equalTo.js +4 -50
  24. package/lib/asserts/common/equalTo.js.map +1 -1
  25. package/lib/asserts/common/equalTo.mjs +4 -23
  26. package/lib/asserts/common/equalTo.mjs.map +1 -1
  27. package/lib/asserts/common/index.d.mts +1 -1
  28. package/lib/asserts/common/index.d.ts +1 -1
  29. package/lib/asserts/common/index.js +6 -68
  30. package/lib/asserts/common/index.js.map +1 -1
  31. package/lib/asserts/common/index.mjs +6 -41
  32. package/lib/asserts/common/index.mjs.map +1 -1
  33. package/lib/asserts/number/index.d.mts +16 -2
  34. package/lib/asserts/number/index.d.ts +16 -2
  35. package/lib/asserts/number/index.js +8 -108
  36. package/lib/asserts/number/index.js.map +1 -1
  37. package/lib/asserts/number/index.mjs +8 -81
  38. package/lib/asserts/number/index.mjs.map +1 -1
  39. package/lib/asserts/number/max.d.mts +1 -1
  40. package/lib/asserts/number/max.d.ts +1 -1
  41. package/lib/asserts/number/max.js +6 -47
  42. package/lib/asserts/number/max.js.map +1 -1
  43. package/lib/asserts/number/max.mjs +3 -17
  44. package/lib/asserts/number/max.mjs.map +1 -1
  45. package/lib/asserts/number/maxExcluded.d.mts +1 -1
  46. package/lib/asserts/number/maxExcluded.d.ts +1 -1
  47. package/lib/asserts/number/maxExcluded.js +6 -47
  48. package/lib/asserts/number/maxExcluded.js.map +1 -1
  49. package/lib/asserts/number/maxExcluded.mjs +3 -17
  50. package/lib/asserts/number/maxExcluded.mjs.map +1 -1
  51. package/lib/asserts/number/min.d.mts +1 -1
  52. package/lib/asserts/number/min.d.ts +1 -1
  53. package/lib/asserts/number/min.js +6 -47
  54. package/lib/asserts/number/min.js.map +1 -1
  55. package/lib/asserts/number/min.mjs +3 -17
  56. package/lib/asserts/number/min.mjs.map +1 -1
  57. package/lib/asserts/number/minExcluded.d.mts +1 -1
  58. package/lib/asserts/number/minExcluded.d.ts +1 -1
  59. package/lib/asserts/number/minExcluded.js +6 -47
  60. package/lib/asserts/number/minExcluded.js.map +1 -1
  61. package/lib/asserts/number/minExcluded.mjs +3 -17
  62. package/lib/asserts/number/minExcluded.mjs.map +1 -1
  63. package/lib/asserts/number/negative.d.mts +1 -1
  64. package/lib/asserts/number/negative.d.ts +1 -1
  65. package/lib/asserts/number/negative.js +6 -47
  66. package/lib/asserts/number/negative.js.map +1 -1
  67. package/lib/asserts/number/negative.mjs +3 -17
  68. package/lib/asserts/number/negative.mjs.map +1 -1
  69. package/lib/asserts/number/positive.d.mts +1 -1
  70. package/lib/asserts/number/positive.d.ts +1 -1
  71. package/lib/asserts/number/positive.js +6 -47
  72. package/lib/asserts/number/positive.js.map +1 -1
  73. package/lib/asserts/number/positive.mjs +3 -17
  74. package/lib/asserts/number/positive.mjs.map +1 -1
  75. package/lib/asserts/object/index.d.mts +21 -2
  76. package/lib/asserts/object/index.d.ts +21 -2
  77. package/lib/asserts/object/index.js +7 -90
  78. package/lib/asserts/object/index.js.map +1 -1
  79. package/lib/asserts/object/index.mjs +7 -63
  80. package/lib/asserts/object/index.mjs.map +1 -1
  81. package/lib/asserts/string/email.d.mts +1 -1
  82. package/lib/asserts/string/email.d.ts +1 -1
  83. package/lib/asserts/string/email.js +6 -47
  84. package/lib/asserts/string/email.js.map +1 -1
  85. package/lib/asserts/string/email.mjs +3 -17
  86. package/lib/asserts/string/email.mjs.map +1 -1
  87. package/lib/asserts/string/index.d.mts +16 -2
  88. package/lib/asserts/string/index.d.ts +16 -2
  89. package/lib/asserts/string/index.js +8 -108
  90. package/lib/asserts/string/index.js.map +1 -1
  91. package/lib/asserts/string/index.mjs +8 -81
  92. package/lib/asserts/string/index.mjs.map +1 -1
  93. package/lib/asserts/string/maxLength.d.mts +1 -1
  94. package/lib/asserts/string/maxLength.d.ts +1 -1
  95. package/lib/asserts/string/maxLength.js +6 -47
  96. package/lib/asserts/string/maxLength.js.map +1 -1
  97. package/lib/asserts/string/maxLength.mjs +3 -17
  98. package/lib/asserts/string/maxLength.mjs.map +1 -1
  99. package/lib/asserts/string/minLength.d.mts +1 -1
  100. package/lib/asserts/string/minLength.d.ts +1 -1
  101. package/lib/asserts/string/minLength.js +6 -47
  102. package/lib/asserts/string/minLength.js.map +1 -1
  103. package/lib/asserts/string/minLength.mjs +3 -17
  104. package/lib/asserts/string/minLength.mjs.map +1 -1
  105. package/lib/asserts/string/regExp.d.mts +1 -1
  106. package/lib/asserts/string/regExp.d.ts +1 -1
  107. package/lib/asserts/string/regExp.js +6 -47
  108. package/lib/asserts/string/regExp.js.map +1 -1
  109. package/lib/asserts/string/regExp.mjs +3 -17
  110. package/lib/asserts/string/regExp.mjs.map +1 -1
  111. package/lib/chunk-2AP4OQMT.js +26 -0
  112. package/lib/chunk-2AP4OQMT.js.map +1 -0
  113. package/lib/chunk-32IQXZRK.mjs +13 -0
  114. package/lib/chunk-32IQXZRK.mjs.map +1 -0
  115. package/lib/chunk-3FEJUC3K.mjs +13 -0
  116. package/lib/chunk-3FEJUC3K.mjs.map +1 -0
  117. package/lib/chunk-5NCJN6D2.js +70 -0
  118. package/lib/chunk-5NCJN6D2.js.map +1 -0
  119. package/lib/chunk-5ZMICHV3.js +21 -0
  120. package/lib/chunk-5ZMICHV3.js.map +1 -0
  121. package/lib/chunk-63IQFNFO.mjs +27 -0
  122. package/lib/chunk-63IQFNFO.mjs.map +1 -0
  123. package/lib/chunk-A2SAWKJA.mjs +13 -0
  124. package/lib/chunk-A2SAWKJA.mjs.map +1 -0
  125. package/lib/chunk-A3UTB4RE.mjs +28 -0
  126. package/lib/chunk-A3UTB4RE.mjs.map +1 -0
  127. package/lib/chunk-A7I2JEQO.js +13 -0
  128. package/lib/chunk-A7I2JEQO.js.map +1 -0
  129. package/lib/chunk-AJ4WV5DG.mjs +13 -0
  130. package/lib/chunk-AJ4WV5DG.mjs.map +1 -0
  131. package/lib/chunk-APTTIN2L.js +42 -0
  132. package/lib/chunk-APTTIN2L.js.map +1 -0
  133. package/lib/chunk-AXOP6HPJ.js +14 -0
  134. package/lib/chunk-AXOP6HPJ.js.map +1 -0
  135. package/lib/chunk-BGMR7A6X.mjs +13 -0
  136. package/lib/chunk-BGMR7A6X.mjs.map +1 -0
  137. package/lib/chunk-FCFO5J5Y.mjs +14 -0
  138. package/lib/chunk-FCFO5J5Y.mjs.map +1 -0
  139. package/lib/chunk-GEZME6V2.mjs +39 -0
  140. package/lib/chunk-GEZME6V2.mjs.map +1 -0
  141. package/lib/chunk-GNBSKTFV.js +27 -0
  142. package/lib/chunk-GNBSKTFV.js.map +1 -0
  143. package/lib/chunk-IQ3QYABE.js +32 -0
  144. package/lib/chunk-IQ3QYABE.js.map +1 -0
  145. package/lib/chunk-K2S3FS5K.js +13 -0
  146. package/lib/chunk-K2S3FS5K.js.map +1 -0
  147. package/lib/chunk-KCBOOOTF.mjs +13 -0
  148. package/lib/chunk-KCBOOOTF.mjs.map +1 -0
  149. package/lib/chunk-L6A7NXUJ.js +13 -0
  150. package/lib/chunk-L6A7NXUJ.js.map +1 -0
  151. package/lib/chunk-L7HUXYFV.mjs +42 -0
  152. package/lib/chunk-L7HUXYFV.mjs.map +1 -0
  153. package/lib/chunk-LHTJHMKJ.mjs +27 -0
  154. package/lib/chunk-LHTJHMKJ.mjs.map +1 -0
  155. package/lib/chunk-NOADI6PO.mjs +21 -0
  156. package/lib/chunk-NOADI6PO.mjs.map +1 -0
  157. package/lib/chunk-NWY33MFU.js +13 -0
  158. package/lib/chunk-NWY33MFU.js.map +1 -0
  159. package/lib/chunk-P3Y6IWFA.mjs +70 -0
  160. package/lib/chunk-P3Y6IWFA.mjs.map +1 -0
  161. package/lib/chunk-PDVXBE27.js +27 -0
  162. package/lib/chunk-PDVXBE27.js.map +1 -0
  163. package/lib/chunk-PJP63SJT.js +13 -0
  164. package/lib/chunk-PJP63SJT.js.map +1 -0
  165. package/lib/chunk-QJOXKH7A.mjs +26 -0
  166. package/lib/chunk-QJOXKH7A.mjs.map +1 -0
  167. package/lib/chunk-QKGQ4XZC.js +13 -0
  168. package/lib/chunk-QKGQ4XZC.js.map +1 -0
  169. package/lib/chunk-QYLH5ZAC.mjs +32 -0
  170. package/lib/chunk-QYLH5ZAC.mjs.map +1 -0
  171. package/lib/chunk-VPFIIM2X.js +39 -0
  172. package/lib/chunk-VPFIIM2X.js.map +1 -0
  173. package/lib/chunk-YXHH5BF6.js +28 -0
  174. package/lib/chunk-YXHH5BF6.js.map +1 -0
  175. package/lib/core.d.mts +1 -0
  176. package/lib/core.d.ts +1 -0
  177. package/lib/core.js +10 -0
  178. package/lib/core.js.map +1 -0
  179. package/lib/core.mjs +10 -0
  180. package/lib/core.mjs.map +1 -0
  181. package/lib/exceptions.d.mts +12 -0
  182. package/lib/exceptions.d.ts +12 -0
  183. package/lib/exceptions.js +11 -0
  184. package/lib/exceptions.js.map +1 -0
  185. package/lib/exceptions.mjs +11 -0
  186. package/lib/exceptions.mjs.map +1 -0
  187. package/lib/index.d.mts +14 -51
  188. package/lib/index.d.ts +14 -51
  189. package/lib/index.js +29 -277
  190. package/lib/index.js.map +1 -1
  191. package/lib/index.mjs +38 -253
  192. package/lib/index.mjs.map +1 -1
  193. package/lib/parseSchema.d.mts +37 -0
  194. package/lib/parseSchema.d.ts +37 -0
  195. package/lib/parseSchema.js +9 -0
  196. package/lib/parseSchema.js.map +1 -0
  197. package/lib/parseSchema.mjs +9 -0
  198. package/lib/parseSchema.mjs.map +1 -0
  199. package/lib/schemas/ArraySchema.d.mts +13 -0
  200. package/lib/schemas/ArraySchema.d.ts +13 -0
  201. package/lib/schemas/ArraySchema.js +10 -0
  202. package/lib/schemas/ArraySchema.js.map +1 -0
  203. package/lib/schemas/ArraySchema.mjs +10 -0
  204. package/lib/schemas/ArraySchema.mjs.map +1 -0
  205. package/lib/{index-nzqBrOHf.d.mts → schemas/BooleanSchema.d.mts} +2 -14
  206. package/lib/{index-B1yBez0g.d.ts → schemas/BooleanSchema.d.ts} +2 -14
  207. package/lib/schemas/BooleanSchema.js +10 -0
  208. package/lib/schemas/BooleanSchema.js.map +1 -0
  209. package/lib/schemas/BooleanSchema.mjs +10 -0
  210. package/lib/schemas/BooleanSchema.mjs.map +1 -0
  211. package/lib/schemas/CommonSchema.d.mts +1 -0
  212. package/lib/schemas/CommonSchema.d.ts +1 -0
  213. package/lib/schemas/CommonSchema.js +9 -0
  214. package/lib/schemas/CommonSchema.js.map +1 -0
  215. package/lib/schemas/CommonSchema.mjs +9 -0
  216. package/lib/schemas/CommonSchema.mjs.map +1 -0
  217. package/lib/{index-B63cXDOm.d.mts → schemas/NumberSchema.d.mts} +2 -14
  218. package/lib/{index-CK_g_aEC.d.ts → schemas/NumberSchema.d.ts} +2 -14
  219. package/lib/schemas/NumberSchema.js +11 -0
  220. package/lib/schemas/NumberSchema.js.map +1 -0
  221. package/lib/schemas/NumberSchema.mjs +11 -0
  222. package/lib/schemas/NumberSchema.mjs.map +1 -0
  223. package/lib/schemas/ObjectSchema.d.mts +12 -0
  224. package/lib/schemas/ObjectSchema.d.ts +12 -0
  225. package/lib/schemas/ObjectSchema.js +10 -0
  226. package/lib/schemas/ObjectSchema.js.map +1 -0
  227. package/lib/schemas/ObjectSchema.mjs +10 -0
  228. package/lib/schemas/ObjectSchema.mjs.map +1 -0
  229. package/lib/{index-aBEYpJdZ.d.mts → schemas/StringSchema.d.mts} +2 -14
  230. package/lib/{index-BEyBEBSm.d.ts → schemas/StringSchema.d.ts} +2 -14
  231. package/lib/schemas/StringSchema.js +11 -0
  232. package/lib/schemas/StringSchema.js.map +1 -0
  233. package/lib/schemas/StringSchema.mjs +11 -0
  234. package/lib/schemas/StringSchema.mjs.map +1 -0
  235. package/package.json +30 -28
  236. package/lib/index-D3R2euaT.d.mts +0 -29
  237. package/lib/index-DPkImfCy.d.ts +0 -29
  238. package/lib/index-DitgsWDO.d.ts +0 -27
  239. package/lib/index-T3KBmyyn.d.mts +0 -27
@@ -1,112 +1,12 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
19
2
 
20
- // src/asserts/string/index.ts
21
- var string_exports = {};
22
- __export(string_exports, {
23
- string: () => string
24
- });
25
- module.exports = __toCommonJS(string_exports);
3
+ var _chunkPJP63SJTjs = require('../../chunk-PJP63SJT.js');
4
+ require('../../chunk-PDVXBE27.js');
5
+ require('../../chunk-AXOP6HPJ.js');
6
+ require('../../chunk-APTTIN2L.js');
7
+ require('../../chunk-5NCJN6D2.js');
8
+ require('../../chunk-2AP4OQMT.js');
26
9
 
27
- // src/exceptions.ts
28
- var ValidationError = class extends Error {
29
- expected;
30
- received;
31
- pathToError;
32
- message;
33
- constructor(expected, received, pathToError, message) {
34
- super();
35
- this.expected = expected;
36
- this.received = received;
37
- this.pathToError = pathToError;
38
- this.message = message;
39
- }
40
- };
41
- function throwException(expected, received, pathToError, message) {
42
- throw new ValidationError(expected, received, pathToError, message);
43
- }
44
10
 
45
- // src/asserts/common/equalTo.ts
46
- var equalTo = (expected) => (received, pathToError) => {
47
- if (expected !== received)
48
- throwException(expected, received, pathToError, "The received value is not equal to expected");
49
- };
50
-
51
- // src/core.ts
52
- var ctxSymbol = Symbol("contextSymbol");
53
-
54
- // src/schemas/CommonSchema.ts
55
- var CommonSchema = class {
56
- [ctxSymbol];
57
- constructor(ctx) {
58
- this[ctxSymbol] = ctx;
59
- }
60
- /**
61
- * @param validators - One or more custom validation functions.
62
- * @returns {this} The schema instance with the added custom validation.
63
- */
64
- custom(...validators) {
65
- this[ctxSymbol].requiredValidations.push(...validators);
66
- return this;
67
- }
68
- /**
69
- * Marks the schema as nullable, allowing the value to be `null`.
70
- *
71
- * @returns {WithNull<this>} The schema instance marked as nullable.
72
- */
73
- nullable() {
74
- this[ctxSymbol].isNullable = true;
75
- return this;
76
- }
77
- /**
78
- * Marks the schema as optional, allowing the value to be `undefined`.
79
- *
80
- * @returns {WithUndefined<this>}} The schema instance marked as optional.
81
- */
82
- optional() {
83
- this[ctxSymbol].isOptional = true;
84
- return this;
85
- }
86
- };
87
-
88
- // src/schemas/StringSchema.ts
89
- var StringSchema = class extends CommonSchema {
90
- _string = 1;
91
- /**
92
- * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
93
- *
94
- * @param expectedValue - The value that the schema must exactly match.
95
- * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
96
- *
97
- * @example - string().equalTo('hello'); // Infers the type 'hello'
98
- */
99
- equalTo(expectedValue) {
100
- return this.custom(equalTo(expectedValue));
101
- }
102
- };
103
-
104
- // src/asserts/string/index.ts
105
- function string() {
106
- return new StringSchema({ type: ["string"], requiredValidations: [] });
107
- }
108
- // Annotate the CommonJS export names for ESM import in node:
109
- 0 && (module.exports = {
110
- string
111
- });
11
+ exports.string = _chunkPJP63SJTjs.string;
112
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/asserts/string/index.ts","../../../src/exceptions.ts","../../../src/asserts/common/equalTo.ts","../../../src/core.ts","../../../src/schemas/CommonSchema.ts","../../../src/schemas/StringSchema.ts"],"sourcesContent":["import { StringSchema } from '../../schemas/StringSchema';\n\n/**\n * Creates a new schema for validating string values.\n *\n * @returns {StringSchema} A new instance of `StringSchema` for validating strings.\n *\n * @example\n * const schema = string();\n * parseSchema(schema, 'hello'); // Validates successfully\n * parseSchema(schema, 123); // Throws a validation error\n */\nexport function string(): StringSchema {\n return new StringSchema({ type: ['string'], requiredValidations: [] });\n}\n","export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Creates a custom assertion that checks if a value is equal to the expected value.\n *\n * This assertion can be used within a `.custom` method to enforce that a value strictly matches the expected value.\n * It will throw a `ValidationError` if the values are not equal.\n *\n * @param {unknown} expected - The value that the received value is expected to match.\n * @returns {RequiredValidation} A function that takes the received value and the path to the error,\n * and throws a `ValidationError` if the received value does not equal the expected value.\n *\n * @throws {ValidationError} If the received value does not match the expected value.\n *\n * @example\n * import { number, equalTo } from 'bguard';\n *\n * // Define a schema with a custom assertion\n * const schema = number().custom(equalTo(5));\n *\n * // This will pass\n * parseSchema(schema, 5);\n *\n * // This will throw a ValidationError\n * parseSchema(schema, 3);\n */\nexport const equalTo =\n (expected: unknown): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected !== received)\n throwException(expected, received, pathToError, 'The received value is not equal to expected');\n };\n","export const ctxSymbol = Symbol('contextSymbol');\n\nimport { throwException } from './exceptions';\nimport type { CommonSchema } from './schemas/CommonSchema';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, pathToError: string) {\n const ctx = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (!ctx.isOptional) throwException('Required', receivedValue, pathToError, 'The required value is missing');\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!ctx.isNullable) throwException('Not null', receivedValue, pathToError, 'Value should not be null');\n return receivedValue;\n }\n\n if (ctx.array) {\n if (!Array.isArray(receivedValue))\n throwException('Array', receivedValue, pathToError, 'Expected an array but received a different type');\n const schema = ctx.array;\n\n receivedValue.forEach((elem, i) => {\n innerCheck(schema, elem, `${pathToError}[${i}]`);\n });\n\n return receivedValue;\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (ctx.object) {\n if (typeOfVal !== 'object')\n throwException('Object', receivedValue, pathToError, 'Expected an object but received a different type');\n if (Array.isArray(receivedValue))\n throwException(\n 'Object',\n receivedValue,\n pathToError,\n 'Expected an object but received an array. Invalid type of data',\n );\n const shapeSchema = ctx.object;\n for (const keyPerReceivedValue of Object.keys(receivedValue)) {\n if (shapeSchema[keyPerReceivedValue] === undefined)\n throwException('Not allowed', keyPerReceivedValue, pathToError, 'This key is not allowed in the object');\n }\n\n for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {\n const receivedObjectValuePropery = (receivedValue as Record<string, unknown>)[keyOfSchema];\n if (receivedObjectValuePropery === undefined) {\n if (!valueOfSchema[ctxSymbol].isOptional)\n throwException(\n 'Required',\n receivedObjectValuePropery,\n pathToError,\n 'Missing required property in the object',\n );\n }\n innerCheck(valueOfSchema, receivedObjectValuePropery, `${pathToError}.${keyOfSchema}`);\n }\n\n return receivedValue;\n }\n\n if (ctx.type.length) {\n if (!ctx.type.includes(typeOfVal)) throwException(ctx.type, typeOfVal, pathToError, 'Invalid type of data');\n }\n\n ctx.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, pathToError);\n });\n\n return receivedValue;\n}\n","import { ctxSymbol } from '../core';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RequiredValidation = (received: any, pathToError: string) => void;\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport type PrimitiveType = 'number' | 'string' | 'boolean' | 'undefined' | 'object' | 'function' | 'symbol' | 'bigint';\nexport interface ValidatorContext {\n type: PrimitiveType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n}\n\nexport class CommonSchema {\n [ctxSymbol]: ValidatorContext;\n constructor(ctx: ValidatorContext) {\n this[ctxSymbol] = ctx;\n }\n\n /**\n * @param validators - One or more custom validation functions.\n * @returns {this} The schema instance with the added custom validation.\n */\n custom(...validators: RequiredValidation[]): this {\n this[ctxSymbol].requiredValidations.push(...validators);\n return this;\n }\n\n /**\n * Marks the schema as nullable, allowing the value to be `null`.\n *\n * @returns {WithNull<this>} The schema instance marked as nullable.\n */\n nullable(): WithNull<this> {\n this[ctxSymbol].isNullable = true;\n return this as WithNull<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {WithUndefined<this>}} The schema instance marked as optional.\n */\n optional(): WithUndefined<this> {\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n}\n\nexport type WithNull<T extends CommonSchema> = T & { validation_null: true };\nexport type WithUndefined<T extends CommonSchema> = T & { validation_undefined: true };\n\ntype TypeMapping = {\n number: number;\n string: string;\n boolean: boolean;\n undefined: undefined;\n object: object;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n function: Function;\n symbol: symbol;\n bigint: bigint;\n};\n\nexport type WithMix<Y = unknown> = CommonSchema & { validation_mix: Y };\nexport type ExtractFromMix<T> = T extends WithMix<infer X> ? X : never;\n\nexport type MapMixTypes<T extends PrimitiveType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n","import { equalTo } from '../asserts/common/equalTo';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACSO,IAAM,UACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,aAAa;AACf,mBAAe,UAAU,UAAU,aAAa,6CAA6C;AACjG;;;AChCK,IAAM,YAAY,OAAO,eAAe;;;ACgBxC,IAAM,eAAN,MAAmB;AAAA,EACxB,CAAC,SAAS;AAAA,EACV,YAAY,KAAuB;AACjC,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAwC;AAChD,SAAK,SAAS,EAAE,oBAAoB,KAAK,GAAG,UAAU;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAA2B;AACzB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAgC;AAC9B,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;;;AC/CO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,QAA0B,eAAuC;AAC/D,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AACF;;;ALLO,SAAS,SAAuB;AACrC,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACvE;","names":[]}
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;AACE;AACF,yCAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/index.js"}
@@ -1,84 +1,11 @@
1
- // src/exceptions.ts
2
- var ValidationError = class extends Error {
3
- expected;
4
- received;
5
- pathToError;
6
- message;
7
- constructor(expected, received, pathToError, message) {
8
- super();
9
- this.expected = expected;
10
- this.received = received;
11
- this.pathToError = pathToError;
12
- this.message = message;
13
- }
14
- };
15
- function throwException(expected, received, pathToError, message) {
16
- throw new ValidationError(expected, received, pathToError, message);
17
- }
18
-
19
- // src/asserts/common/equalTo.ts
20
- var equalTo = (expected) => (received, pathToError) => {
21
- if (expected !== received)
22
- throwException(expected, received, pathToError, "The received value is not equal to expected");
23
- };
24
-
25
- // src/core.ts
26
- var ctxSymbol = Symbol("contextSymbol");
27
-
28
- // src/schemas/CommonSchema.ts
29
- var CommonSchema = class {
30
- [ctxSymbol];
31
- constructor(ctx) {
32
- this[ctxSymbol] = ctx;
33
- }
34
- /**
35
- * @param validators - One or more custom validation functions.
36
- * @returns {this} The schema instance with the added custom validation.
37
- */
38
- custom(...validators) {
39
- this[ctxSymbol].requiredValidations.push(...validators);
40
- return this;
41
- }
42
- /**
43
- * Marks the schema as nullable, allowing the value to be `null`.
44
- *
45
- * @returns {WithNull<this>} The schema instance marked as nullable.
46
- */
47
- nullable() {
48
- this[ctxSymbol].isNullable = true;
49
- return this;
50
- }
51
- /**
52
- * Marks the schema as optional, allowing the value to be `undefined`.
53
- *
54
- * @returns {WithUndefined<this>}} The schema instance marked as optional.
55
- */
56
- optional() {
57
- this[ctxSymbol].isOptional = true;
58
- return this;
59
- }
60
- };
61
-
62
- // src/schemas/StringSchema.ts
63
- var StringSchema = class extends CommonSchema {
64
- _string = 1;
65
- /**
66
- * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
67
- *
68
- * @param expectedValue - The value that the schema must exactly match.
69
- * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
70
- *
71
- * @example - string().equalTo('hello'); // Infers the type 'hello'
72
- */
73
- equalTo(expectedValue) {
74
- return this.custom(equalTo(expectedValue));
75
- }
76
- };
77
-
78
- // src/asserts/string/index.ts
79
- function string() {
80
- return new StringSchema({ type: ["string"], requiredValidations: [] });
81
- }
1
+ import {
2
+ string
3
+ } from "../../chunk-KCBOOOTF.mjs";
4
+ import "../../chunk-LHTJHMKJ.mjs";
5
+ import "../../chunk-FCFO5J5Y.mjs";
6
+ import "../../chunk-L7HUXYFV.mjs";
7
+ import "../../chunk-P3Y6IWFA.mjs";
8
+ import "../../chunk-QJOXKH7A.mjs";
82
9
  export {
83
10
  string
84
11
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/common/equalTo.ts","../../../src/core.ts","../../../src/schemas/CommonSchema.ts","../../../src/schemas/StringSchema.ts","../../../src/asserts/string/index.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Creates a custom assertion that checks if a value is equal to the expected value.\n *\n * This assertion can be used within a `.custom` method to enforce that a value strictly matches the expected value.\n * It will throw a `ValidationError` if the values are not equal.\n *\n * @param {unknown} expected - The value that the received value is expected to match.\n * @returns {RequiredValidation} A function that takes the received value and the path to the error,\n * and throws a `ValidationError` if the received value does not equal the expected value.\n *\n * @throws {ValidationError} If the received value does not match the expected value.\n *\n * @example\n * import { number, equalTo } from 'bguard';\n *\n * // Define a schema with a custom assertion\n * const schema = number().custom(equalTo(5));\n *\n * // This will pass\n * parseSchema(schema, 5);\n *\n * // This will throw a ValidationError\n * parseSchema(schema, 3);\n */\nexport const equalTo =\n (expected: unknown): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected !== received)\n throwException(expected, received, pathToError, 'The received value is not equal to expected');\n };\n","export const ctxSymbol = Symbol('contextSymbol');\n\nimport { throwException } from './exceptions';\nimport type { CommonSchema } from './schemas/CommonSchema';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, pathToError: string) {\n const ctx = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (!ctx.isOptional) throwException('Required', receivedValue, pathToError, 'The required value is missing');\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!ctx.isNullable) throwException('Not null', receivedValue, pathToError, 'Value should not be null');\n return receivedValue;\n }\n\n if (ctx.array) {\n if (!Array.isArray(receivedValue))\n throwException('Array', receivedValue, pathToError, 'Expected an array but received a different type');\n const schema = ctx.array;\n\n receivedValue.forEach((elem, i) => {\n innerCheck(schema, elem, `${pathToError}[${i}]`);\n });\n\n return receivedValue;\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (ctx.object) {\n if (typeOfVal !== 'object')\n throwException('Object', receivedValue, pathToError, 'Expected an object but received a different type');\n if (Array.isArray(receivedValue))\n throwException(\n 'Object',\n receivedValue,\n pathToError,\n 'Expected an object but received an array. Invalid type of data',\n );\n const shapeSchema = ctx.object;\n for (const keyPerReceivedValue of Object.keys(receivedValue)) {\n if (shapeSchema[keyPerReceivedValue] === undefined)\n throwException('Not allowed', keyPerReceivedValue, pathToError, 'This key is not allowed in the object');\n }\n\n for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {\n const receivedObjectValuePropery = (receivedValue as Record<string, unknown>)[keyOfSchema];\n if (receivedObjectValuePropery === undefined) {\n if (!valueOfSchema[ctxSymbol].isOptional)\n throwException(\n 'Required',\n receivedObjectValuePropery,\n pathToError,\n 'Missing required property in the object',\n );\n }\n innerCheck(valueOfSchema, receivedObjectValuePropery, `${pathToError}.${keyOfSchema}`);\n }\n\n return receivedValue;\n }\n\n if (ctx.type.length) {\n if (!ctx.type.includes(typeOfVal)) throwException(ctx.type, typeOfVal, pathToError, 'Invalid type of data');\n }\n\n ctx.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, pathToError);\n });\n\n return receivedValue;\n}\n","import { ctxSymbol } from '../core';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RequiredValidation = (received: any, pathToError: string) => void;\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport type PrimitiveType = 'number' | 'string' | 'boolean' | 'undefined' | 'object' | 'function' | 'symbol' | 'bigint';\nexport interface ValidatorContext {\n type: PrimitiveType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n}\n\nexport class CommonSchema {\n [ctxSymbol]: ValidatorContext;\n constructor(ctx: ValidatorContext) {\n this[ctxSymbol] = ctx;\n }\n\n /**\n * @param validators - One or more custom validation functions.\n * @returns {this} The schema instance with the added custom validation.\n */\n custom(...validators: RequiredValidation[]): this {\n this[ctxSymbol].requiredValidations.push(...validators);\n return this;\n }\n\n /**\n * Marks the schema as nullable, allowing the value to be `null`.\n *\n * @returns {WithNull<this>} The schema instance marked as nullable.\n */\n nullable(): WithNull<this> {\n this[ctxSymbol].isNullable = true;\n return this as WithNull<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {WithUndefined<this>}} The schema instance marked as optional.\n */\n optional(): WithUndefined<this> {\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n}\n\nexport type WithNull<T extends CommonSchema> = T & { validation_null: true };\nexport type WithUndefined<T extends CommonSchema> = T & { validation_undefined: true };\n\ntype TypeMapping = {\n number: number;\n string: string;\n boolean: boolean;\n undefined: undefined;\n object: object;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n function: Function;\n symbol: symbol;\n bigint: bigint;\n};\n\nexport type WithMix<Y = unknown> = CommonSchema & { validation_mix: Y };\nexport type ExtractFromMix<T> = T extends WithMix<infer X> ? X : never;\n\nexport type MapMixTypes<T extends PrimitiveType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n","import { equalTo } from '../asserts/common/equalTo';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n","import { StringSchema } from '../../schemas/StringSchema';\n\n/**\n * Creates a new schema for validating string values.\n *\n * @returns {StringSchema} A new instance of `StringSchema` for validating strings.\n *\n * @example\n * const schema = string();\n * parseSchema(schema, 'hello'); // Validates successfully\n * parseSchema(schema, 123); // Throws a validation error\n */\nexport function string(): StringSchema {\n return new StringSchema({ type: ['string'], requiredValidations: [] });\n}\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACSO,IAAM,UACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,aAAa;AACf,mBAAe,UAAU,UAAU,aAAa,6CAA6C;AACjG;;;AChCK,IAAM,YAAY,OAAO,eAAe;;;ACgBxC,IAAM,eAAN,MAAmB;AAAA,EACxB,CAAC,SAAS;AAAA,EACV,YAAY,KAAuB;AACjC,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAwC;AAChD,SAAK,SAAS,EAAE,oBAAoB,KAAK,GAAG,UAAU;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAA2B;AACzB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAgC;AAC9B,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;;;AC/CO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,QAA0B,eAAuC;AAC/D,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AACF;;;ACLO,SAAS,SAAuB;AACrC,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACvE;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,4 +1,4 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.mjs';
1
+ import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.mjs';
2
2
 
3
3
  /**
4
4
  * Asserts that the length of a string value is not greater than a specified maximum length.
@@ -1,4 +1,4 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.js';
1
+ import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.js';
2
2
 
3
3
  /**
4
4
  * Asserts that the length of a string value is not greater than a specified maximum length.
@@ -1,54 +1,13 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
19
2
 
20
- // src/asserts/string/maxLength.ts
21
- var maxLength_exports = {};
22
- __export(maxLength_exports, {
23
- maxLength: () => maxLength
24
- });
25
- module.exports = __toCommonJS(maxLength_exports);
26
-
27
- // src/exceptions.ts
28
- var ValidationError = class extends Error {
29
- expected;
30
- received;
31
- pathToError;
32
- message;
33
- constructor(expected, received, pathToError, message) {
34
- super();
35
- this.expected = expected;
36
- this.received = received;
37
- this.pathToError = pathToError;
38
- this.message = message;
39
- }
40
- };
41
- function throwException(expected, received, pathToError, message) {
42
- throw new ValidationError(expected, received, pathToError, message);
43
- }
3
+ var _chunk2AP4OQMTjs = require('../../chunk-2AP4OQMT.js');
44
4
 
45
5
  // src/asserts/string/maxLength.ts
46
6
  var maxLength = (expected) => (received, pathToError) => {
47
7
  if (received.length > expected)
48
- throwException(expected, received, pathToError, "The received value length is greater than expected");
8
+ _chunk2AP4OQMTjs.throwException.call(void 0, expected, received, pathToError, "The received value length is greater than expected");
49
9
  };
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- maxLength
53
- });
10
+
11
+
12
+ exports.maxLength = maxLength;
54
13
  //# sourceMappingURL=maxLength.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/asserts/string/maxLength.ts","../../../src/exceptions.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not greater than a specified maximum length.\n *\n * @param {number} expected - The maximum allowed length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is greater than the expected length.\n *\n * @example\n * const schema = string().custom(maxLength(10));\n * parseSchema(schema, 'short'); // Valid\n * parseSchema(schema, 'this is a very long string'); // Throws an error: 'The received value length is greater than expected'\n */\nexport const maxLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length > expected)\n throwException(expected, received, pathToError, 'The received value length is greater than expected');\n };\n","export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ADJO,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,SAAS,SAAS;AACpB,mBAAe,UAAU,UAAU,aAAa,oDAAoD;AACxG;","names":[]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/maxLength.js","../../../src/asserts/string/maxLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACA;ACUO,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AACzC,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA;AACpB,IAAA,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,oDAAoD,CAAA;AACxG,CAAA;ADVF;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/maxLength.js","sourcesContent":[null,"import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not greater than a specified maximum length.\n *\n * @param {number} expected - The maximum allowed length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is greater than the expected length.\n *\n * @example\n * const schema = string().custom(maxLength(10));\n * parseSchema(schema, 'short'); // Valid\n * parseSchema(schema, 'this is a very long string'); // Throws an error: 'The received value length is greater than expected'\n */\nexport const maxLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length > expected)\n throwException(expected, received, pathToError, 'The received value length is greater than expected');\n };\n"]}
@@ -1,20 +1,6 @@
1
- // src/exceptions.ts
2
- var ValidationError = class extends Error {
3
- expected;
4
- received;
5
- pathToError;
6
- message;
7
- constructor(expected, received, pathToError, message) {
8
- super();
9
- this.expected = expected;
10
- this.received = received;
11
- this.pathToError = pathToError;
12
- this.message = message;
13
- }
14
- };
15
- function throwException(expected, received, pathToError, message) {
16
- throw new ValidationError(expected, received, pathToError, message);
17
- }
1
+ import {
2
+ throwException
3
+ } from "../../chunk-QJOXKH7A.mjs";
18
4
 
19
5
  // src/asserts/string/maxLength.ts
20
6
  var maxLength = (expected) => (received, pathToError) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/string/maxLength.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not greater than a specified maximum length.\n *\n * @param {number} expected - The maximum allowed length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is greater than the expected length.\n *\n * @example\n * const schema = string().custom(maxLength(10));\n * parseSchema(schema, 'short'); // Valid\n * parseSchema(schema, 'this is a very long string'); // Throws an error: 'The received value length is greater than expected'\n */\nexport const maxLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length > expected)\n throwException(expected, received, pathToError, 'The received value length is greater than expected');\n };\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACJO,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,SAAS,SAAS;AACpB,mBAAe,UAAU,UAAU,aAAa,oDAAoD;AACxG;","names":[]}
1
+ {"version":3,"sources":["../../../src/asserts/string/maxLength.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not greater than a specified maximum length.\n *\n * @param {number} expected - The maximum allowed length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is greater than the expected length.\n *\n * @example\n * const schema = string().custom(maxLength(10));\n * parseSchema(schema, 'short'); // Valid\n * parseSchema(schema, 'this is a very long string'); // Throws an error: 'The received value length is greater than expected'\n */\nexport const maxLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length > expected)\n throwException(expected, received, pathToError, 'The received value length is greater than expected');\n };\n"],"mappings":";;;;;AAcO,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,SAAS,SAAS;AACpB,mBAAe,UAAU,UAAU,aAAa,oDAAoD;AACxG;","names":[]}
@@ -1,4 +1,4 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.mjs';
1
+ import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.mjs';
2
2
 
3
3
  /**
4
4
  * Asserts that the length of a string value is not less than a specified minimum length.
@@ -1,4 +1,4 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.js';
1
+ import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.js';
2
2
 
3
3
  /**
4
4
  * Asserts that the length of a string value is not less than a specified minimum length.
@@ -1,54 +1,13 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
19
2
 
20
- // src/asserts/string/minLength.ts
21
- var minLength_exports = {};
22
- __export(minLength_exports, {
23
- minLength: () => minLength
24
- });
25
- module.exports = __toCommonJS(minLength_exports);
26
-
27
- // src/exceptions.ts
28
- var ValidationError = class extends Error {
29
- expected;
30
- received;
31
- pathToError;
32
- message;
33
- constructor(expected, received, pathToError, message) {
34
- super();
35
- this.expected = expected;
36
- this.received = received;
37
- this.pathToError = pathToError;
38
- this.message = message;
39
- }
40
- };
41
- function throwException(expected, received, pathToError, message) {
42
- throw new ValidationError(expected, received, pathToError, message);
43
- }
3
+ var _chunk2AP4OQMTjs = require('../../chunk-2AP4OQMT.js');
44
4
 
45
5
  // src/asserts/string/minLength.ts
46
6
  var minLength = (expected) => (received, pathToError) => {
47
7
  if (received.length < expected)
48
- throwException(expected, received, pathToError, "The received value length is less than expected");
8
+ _chunk2AP4OQMTjs.throwException.call(void 0, expected, received, pathToError, "The received value length is less than expected");
49
9
  };
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- minLength
53
- });
10
+
11
+
12
+ exports.minLength = minLength;
54
13
  //# sourceMappingURL=minLength.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/asserts/string/minLength.ts","../../../src/exceptions.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not less than a specified minimum length.\n *\n * @param {number} expected - The minimum required length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.\n *\n * @example\n * const schema = string().custom(minLength(5));\n * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseSchema(schema, 'adequate'); // Valid\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length < expected)\n throwException(expected, received, pathToError, 'The received value length is less than expected');\n };\n","export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ADJO,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,SAAS,SAAS;AACpB,mBAAe,UAAU,UAAU,aAAa,iDAAiD;AACrG;","names":[]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","../../../src/asserts/string/minLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACA;ACUO,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AACzC,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA;AACpB,IAAA,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,iDAAiD,CAAA;AACrG,CAAA;ADVF;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","sourcesContent":[null,"import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not less than a specified minimum length.\n *\n * @param {number} expected - The minimum required length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.\n *\n * @example\n * const schema = string().custom(minLength(5));\n * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseSchema(schema, 'adequate'); // Valid\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length < expected)\n throwException(expected, received, pathToError, 'The received value length is less than expected');\n };\n"]}
@@ -1,20 +1,6 @@
1
- // src/exceptions.ts
2
- var ValidationError = class extends Error {
3
- expected;
4
- received;
5
- pathToError;
6
- message;
7
- constructor(expected, received, pathToError, message) {
8
- super();
9
- this.expected = expected;
10
- this.received = received;
11
- this.pathToError = pathToError;
12
- this.message = message;
13
- }
14
- };
15
- function throwException(expected, received, pathToError, message) {
16
- throw new ValidationError(expected, received, pathToError, message);
17
- }
1
+ import {
2
+ throwException
3
+ } from "../../chunk-QJOXKH7A.mjs";
18
4
 
19
5
  // src/asserts/string/minLength.ts
20
6
  var minLength = (expected) => (received, pathToError) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/string/minLength.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not less than a specified minimum length.\n *\n * @param {number} expected - The minimum required length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.\n *\n * @example\n * const schema = string().custom(minLength(5));\n * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseSchema(schema, 'adequate'); // Valid\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length < expected)\n throwException(expected, received, pathToError, 'The received value length is less than expected');\n };\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACJO,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,SAAS,SAAS;AACpB,mBAAe,UAAU,UAAU,aAAa,iDAAiD;AACrG;","names":[]}
1
+ {"version":3,"sources":["../../../src/asserts/string/minLength.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not less than a specified minimum length.\n *\n * @param {number} expected - The minimum required length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.\n *\n * @example\n * const schema = string().custom(minLength(5));\n * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseSchema(schema, 'adequate'); // Valid\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length < expected)\n throwException(expected, received, pathToError, 'The received value length is less than expected');\n };\n"],"mappings":";;;;;AAcO,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,SAAS,SAAS;AACpB,mBAAe,UAAU,UAAU,aAAa,iDAAiD;AACrG;","names":[]}
@@ -1,4 +1,4 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.mjs';
1
+ import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.mjs';
2
2
 
3
3
  /**
4
4
  * Asserts that a string value matches a specified regular expression pattern.
@@ -1,4 +1,4 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.js';
1
+ import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.js';
2
2
 
3
3
  /**
4
4
  * Asserts that a string value matches a specified regular expression pattern.
@@ -1,54 +1,13 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
19
2
 
20
- // src/asserts/string/regExp.ts
21
- var regExp_exports = {};
22
- __export(regExp_exports, {
23
- regExp: () => regExp
24
- });
25
- module.exports = __toCommonJS(regExp_exports);
26
-
27
- // src/exceptions.ts
28
- var ValidationError = class extends Error {
29
- expected;
30
- received;
31
- pathToError;
32
- message;
33
- constructor(expected, received, pathToError, message) {
34
- super();
35
- this.expected = expected;
36
- this.received = received;
37
- this.pathToError = pathToError;
38
- this.message = message;
39
- }
40
- };
41
- function throwException(expected, received, pathToError, message) {
42
- throw new ValidationError(expected, received, pathToError, message);
43
- }
3
+ var _chunk2AP4OQMTjs = require('../../chunk-2AP4OQMT.js');
44
4
 
45
5
  // src/asserts/string/regExp.ts
46
6
  var regExp = (expected) => (received, pathToError) => {
47
7
  if (!expected.test(received))
48
- throwException(expected, received, pathToError, "The received value does not match the required text pattern");
8
+ _chunk2AP4OQMTjs.throwException.call(void 0, expected, received, pathToError, "The received value does not match the required text pattern");
49
9
  };
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- regExp
53
- });
10
+
11
+
12
+ exports.regExp = regExp;
54
13
  //# sourceMappingURL=regExp.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/asserts/string/regExp.ts","../../../src/exceptions.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a string value matches a specified regular expression pattern.\n *\n * @param {RegExp} expected - The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.\n *\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseSchema(schema, 'valid123'); // Valid\n * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (!expected.test(received))\n throwException(expected, received, pathToError, 'The received value does not match the required text pattern');\n };\n","export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ADJO,IAAM,SACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,CAAC,SAAS,KAAK,QAAQ;AACzB,mBAAe,UAAU,UAAU,aAAa,6DAA6D;AACjH;","names":[]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","../../../src/asserts/string/regExp.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACA;ACUO,IAAM,OAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AACzC,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AACzB,IAAA,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,6DAA6D,CAAA;AACjH,CAAA;ADVF;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","sourcesContent":[null,"import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a string value matches a specified regular expression pattern.\n *\n * @param {RegExp} expected - The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.\n *\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseSchema(schema, 'valid123'); // Valid\n * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (!expected.test(received))\n throwException(expected, received, pathToError, 'The received value does not match the required text pattern');\n };\n"]}
@@ -1,20 +1,6 @@
1
- // src/exceptions.ts
2
- var ValidationError = class extends Error {
3
- expected;
4
- received;
5
- pathToError;
6
- message;
7
- constructor(expected, received, pathToError, message) {
8
- super();
9
- this.expected = expected;
10
- this.received = received;
11
- this.pathToError = pathToError;
12
- this.message = message;
13
- }
14
- };
15
- function throwException(expected, received, pathToError, message) {
16
- throw new ValidationError(expected, received, pathToError, message);
17
- }
1
+ import {
2
+ throwException
3
+ } from "../../chunk-QJOXKH7A.mjs";
18
4
 
19
5
  // src/asserts/string/regExp.ts
20
6
  var regExp = (expected) => (received, pathToError) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/string/regExp.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a string value matches a specified regular expression pattern.\n *\n * @param {RegExp} expected - The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.\n *\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseSchema(schema, 'valid123'); // Valid\n * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (!expected.test(received))\n throwException(expected, received, pathToError, 'The received value does not match the required text pattern');\n };\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACJO,IAAM,SACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,CAAC,SAAS,KAAK,QAAQ;AACzB,mBAAe,UAAU,UAAU,aAAa,6DAA6D;AACjH;","names":[]}
1
+ {"version":3,"sources":["../../../src/asserts/string/regExp.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a string value matches a specified regular expression pattern.\n *\n * @param {RegExp} expected - The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.\n *\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseSchema(schema, 'valid123'); // Valid\n * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (!expected.test(received))\n throwException(expected, received, pathToError, 'The received value does not match the required text pattern');\n };\n"],"mappings":";;;;;AAcO,IAAM,SACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,CAAC,SAAS,KAAK,QAAQ;AACzB,mBAAe,UAAU,UAAU,aAAa,6DAA6D;AACjH;","names":[]}