bguard 0.1.0 → 0.1.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 (159) hide show
  1. package/README.md +359 -25
  2. package/lib/asserts/number/index.js +4 -3
  3. package/lib/asserts/number/index.js.map +1 -1
  4. package/lib/asserts/number/index.mjs +3 -2
  5. package/lib/asserts/string/atLeastOneDigit.d.mts +20 -0
  6. package/lib/asserts/string/atLeastOneDigit.d.ts +20 -0
  7. package/lib/asserts/string/atLeastOneDigit.js +21 -0
  8. package/lib/asserts/string/atLeastOneDigit.js.map +1 -0
  9. package/lib/asserts/string/atLeastOneDigit.mjs +21 -0
  10. package/lib/asserts/string/atLeastOneDigit.mjs.map +1 -0
  11. package/lib/asserts/string/atLeastOneLowerChar.d.mts +20 -0
  12. package/lib/asserts/string/atLeastOneLowerChar.d.ts +20 -0
  13. package/lib/asserts/string/atLeastOneLowerChar.js +22 -0
  14. package/lib/asserts/string/atLeastOneLowerChar.js.map +1 -0
  15. package/lib/asserts/string/atLeastOneLowerChar.mjs +22 -0
  16. package/lib/asserts/string/atLeastOneLowerChar.mjs.map +1 -0
  17. package/lib/asserts/string/atLeastOneSpecialChar.d.mts +25 -0
  18. package/lib/asserts/string/atLeastOneSpecialChar.d.ts +25 -0
  19. package/lib/asserts/string/atLeastOneSpecialChar.js +26 -0
  20. package/lib/asserts/string/atLeastOneSpecialChar.js.map +1 -0
  21. package/lib/asserts/string/atLeastOneSpecialChar.mjs +26 -0
  22. package/lib/asserts/string/atLeastOneSpecialChar.mjs.map +1 -0
  23. package/lib/asserts/string/atLeastOneUpperChar.d.mts +20 -0
  24. package/lib/asserts/string/atLeastOneUpperChar.d.ts +20 -0
  25. package/lib/asserts/string/atLeastOneUpperChar.js +22 -0
  26. package/lib/asserts/string/atLeastOneUpperChar.js.map +1 -0
  27. package/lib/asserts/string/atLeastOneUpperChar.mjs +22 -0
  28. package/lib/asserts/string/atLeastOneUpperChar.mjs.map +1 -0
  29. package/lib/asserts/string/contains.d.mts +21 -0
  30. package/lib/asserts/string/contains.d.ts +21 -0
  31. package/lib/asserts/string/contains.js +22 -0
  32. package/lib/asserts/string/contains.js.map +1 -0
  33. package/lib/asserts/string/contains.mjs +22 -0
  34. package/lib/asserts/string/contains.mjs.map +1 -0
  35. package/lib/asserts/string/endsWith.d.mts +21 -0
  36. package/lib/asserts/string/endsWith.d.ts +21 -0
  37. package/lib/asserts/string/endsWith.js +22 -0
  38. package/lib/asserts/string/endsWith.js.map +1 -0
  39. package/lib/asserts/string/endsWith.mjs +22 -0
  40. package/lib/asserts/string/endsWith.mjs.map +1 -0
  41. package/lib/asserts/string/index.js +4 -3
  42. package/lib/asserts/string/index.js.map +1 -1
  43. package/lib/asserts/string/index.mjs +3 -2
  44. package/lib/asserts/string/lowerCase.d.mts +20 -0
  45. package/lib/asserts/string/lowerCase.d.ts +20 -0
  46. package/lib/asserts/string/lowerCase.js +20 -0
  47. package/lib/asserts/string/lowerCase.js.map +1 -0
  48. package/lib/asserts/string/lowerCase.mjs +20 -0
  49. package/lib/asserts/string/lowerCase.mjs.map +1 -0
  50. package/lib/asserts/string/maxLength.d.mts +1 -1
  51. package/lib/asserts/string/maxLength.d.ts +1 -1
  52. package/lib/asserts/string/maxLength.js.map +1 -1
  53. package/lib/asserts/string/maxLength.mjs.map +1 -1
  54. package/lib/asserts/string/minLength.d.mts +1 -1
  55. package/lib/asserts/string/minLength.d.ts +1 -1
  56. package/lib/asserts/string/minLength.js.map +1 -1
  57. package/lib/asserts/string/minLength.mjs.map +1 -1
  58. package/lib/asserts/string/regExp.d.mts +1 -1
  59. package/lib/asserts/string/regExp.d.ts +1 -1
  60. package/lib/asserts/string/regExp.js.map +1 -1
  61. package/lib/asserts/string/regExp.mjs.map +1 -1
  62. package/lib/asserts/string/startsWith.d.mts +21 -0
  63. package/lib/asserts/string/startsWith.d.ts +21 -0
  64. package/lib/asserts/string/startsWith.js +22 -0
  65. package/lib/asserts/string/startsWith.js.map +1 -0
  66. package/lib/asserts/string/startsWith.mjs +22 -0
  67. package/lib/asserts/string/startsWith.mjs.map +1 -0
  68. package/lib/asserts/string/upperCase.d.mts +21 -0
  69. package/lib/asserts/string/upperCase.d.ts +21 -0
  70. package/lib/asserts/string/upperCase.js +22 -0
  71. package/lib/asserts/string/upperCase.js.map +1 -0
  72. package/lib/asserts/string/upperCase.mjs +22 -0
  73. package/lib/asserts/string/upperCase.mjs.map +1 -0
  74. package/lib/asserts/string/uuid.d.mts +20 -0
  75. package/lib/asserts/string/uuid.d.ts +20 -0
  76. package/lib/asserts/string/uuid.js +23 -0
  77. package/lib/asserts/string/uuid.js.map +1 -0
  78. package/lib/asserts/string/uuid.mjs +23 -0
  79. package/lib/asserts/string/uuid.mjs.map +1 -0
  80. package/lib/asserts/string/uuidV1.d.mts +21 -0
  81. package/lib/asserts/string/uuidV1.d.ts +21 -0
  82. package/lib/asserts/string/uuidV1.js +23 -0
  83. package/lib/asserts/string/uuidV1.js.map +1 -0
  84. package/lib/asserts/string/uuidV1.mjs +23 -0
  85. package/lib/asserts/string/uuidV1.mjs.map +1 -0
  86. package/lib/asserts/string/uuidV2.d.mts +21 -0
  87. package/lib/asserts/string/uuidV2.d.ts +21 -0
  88. package/lib/asserts/string/uuidV2.js +23 -0
  89. package/lib/asserts/string/uuidV2.js.map +1 -0
  90. package/lib/asserts/string/uuidV2.mjs +23 -0
  91. package/lib/asserts/string/uuidV2.mjs.map +1 -0
  92. package/lib/asserts/string/uuidV3.d.mts +21 -0
  93. package/lib/asserts/string/uuidV3.d.ts +21 -0
  94. package/lib/asserts/string/uuidV3.js +23 -0
  95. package/lib/asserts/string/uuidV3.js.map +1 -0
  96. package/lib/asserts/string/uuidV3.mjs +23 -0
  97. package/lib/asserts/string/uuidV3.mjs.map +1 -0
  98. package/lib/asserts/string/uuidV4.d.mts +23 -0
  99. package/lib/asserts/string/uuidV4.d.ts +23 -0
  100. package/lib/asserts/string/uuidV4.js +23 -0
  101. package/lib/asserts/string/uuidV4.js.map +1 -0
  102. package/lib/asserts/string/uuidV4.mjs +23 -0
  103. package/lib/asserts/string/uuidV4.mjs.map +1 -0
  104. package/lib/asserts/string/uuidV5.d.mts +21 -0
  105. package/lib/asserts/string/uuidV5.d.ts +21 -0
  106. package/lib/asserts/string/uuidV5.js +23 -0
  107. package/lib/asserts/string/uuidV5.js.map +1 -0
  108. package/lib/asserts/string/uuidV5.mjs +23 -0
  109. package/lib/asserts/string/uuidV5.mjs.map +1 -0
  110. package/lib/asserts/string/validUrl.d.mts +23 -0
  111. package/lib/asserts/string/validUrl.d.ts +23 -0
  112. package/lib/asserts/string/validUrl.js +32 -0
  113. package/lib/asserts/string/validUrl.js.map +1 -0
  114. package/lib/asserts/string/validUrl.mjs +32 -0
  115. package/lib/asserts/string/validUrl.mjs.map +1 -0
  116. package/lib/{chunk-NTC2XQ36.mjs → chunk-32RSTOZ4.mjs} +2 -2
  117. package/lib/chunk-42J6CHIO.js +7 -0
  118. package/lib/chunk-42J6CHIO.js.map +1 -0
  119. package/lib/chunk-ASZW6XRM.mjs +7 -0
  120. package/lib/chunk-ASZW6XRM.mjs.map +1 -0
  121. package/lib/{chunk-FTLRX2XG.mjs → chunk-JPRCULRQ.mjs} +12 -1
  122. package/lib/chunk-JPRCULRQ.mjs.map +1 -0
  123. package/lib/{chunk-RQH4LXBW.js → chunk-KQKJASVB.js} +12 -1
  124. package/lib/chunk-KQKJASVB.js.map +1 -0
  125. package/lib/{chunk-F5MSBL33.js → chunk-LEQCDD66.js} +12 -1
  126. package/lib/chunk-LEQCDD66.js.map +1 -0
  127. package/lib/{chunk-CLG3QRZC.mjs → chunk-P7IXNCJG.mjs} +12 -1
  128. package/lib/chunk-P7IXNCJG.mjs.map +1 -0
  129. package/lib/{chunk-B6TFELXR.mjs → chunk-PXBAS3GA.mjs} +2 -2
  130. package/lib/{chunk-4RNK3I74.js → chunk-RD6TBCPQ.js} +3 -3
  131. package/lib/{chunk-4RNK3I74.js.map → chunk-RD6TBCPQ.js.map} +1 -1
  132. package/lib/{chunk-RL4MSI7R.js → chunk-TKZ6FLLR.js} +3 -3
  133. package/lib/{chunk-RL4MSI7R.js.map → chunk-TKZ6FLLR.js.map} +1 -1
  134. package/lib/helpers/constants.d.mts +3 -0
  135. package/lib/helpers/constants.d.ts +3 -0
  136. package/lib/helpers/constants.js +7 -0
  137. package/lib/helpers/constants.js.map +1 -0
  138. package/lib/helpers/constants.mjs +7 -0
  139. package/lib/helpers/constants.mjs.map +1 -0
  140. package/lib/index.js +8 -7
  141. package/lib/index.js.map +1 -1
  142. package/lib/index.mjs +8 -7
  143. package/lib/schemas/NumberSchema.d.mts +1 -0
  144. package/lib/schemas/NumberSchema.d.ts +1 -0
  145. package/lib/schemas/NumberSchema.js +3 -2
  146. package/lib/schemas/NumberSchema.js.map +1 -1
  147. package/lib/schemas/NumberSchema.mjs +2 -1
  148. package/lib/schemas/StringSchema.d.mts +1 -0
  149. package/lib/schemas/StringSchema.d.ts +1 -0
  150. package/lib/schemas/StringSchema.js +3 -2
  151. package/lib/schemas/StringSchema.js.map +1 -1
  152. package/lib/schemas/StringSchema.mjs +2 -1
  153. package/package.json +1 -1
  154. package/lib/chunk-CLG3QRZC.mjs.map +0 -1
  155. package/lib/chunk-F5MSBL33.js.map +0 -1
  156. package/lib/chunk-FTLRX2XG.mjs.map +0 -1
  157. package/lib/chunk-RQH4LXBW.js.map +0 -1
  158. /package/lib/{chunk-NTC2XQ36.mjs.map → chunk-32RSTOZ4.mjs.map} +0 -0
  159. /package/lib/{chunk-B6TFELXR.mjs.map → chunk-PXBAS3GA.mjs.map} +0 -0
@@ -4,16 +4,23 @@ import {
4
4
  import {
5
5
  oneOfValues
6
6
  } from "./chunk-3O4WCRC2.mjs";
7
+ import {
8
+ ONLY_ONCE
9
+ } from "./chunk-ASZW6XRM.mjs";
7
10
  import {
8
11
  _setStrictType
9
12
  } from "./chunk-RYVUYVEE.mjs";
10
13
  import {
11
14
  CommonSchema
12
15
  } from "./chunk-DPBE7TAQ.mjs";
16
+ import {
17
+ BuildSchemaError
18
+ } from "./chunk-7XFLH6R2.mjs";
13
19
 
14
20
  // src/schemas/StringSchema.ts
15
21
  var StringSchema = class extends CommonSchema {
16
22
  _string = 1;
23
+ limit;
17
24
  /**
18
25
  * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
19
26
  *
@@ -23,6 +30,8 @@ var StringSchema = class extends CommonSchema {
23
30
  * @example - string().equalTo('hello'); // Infers the type 'hello'
24
31
  */
25
32
  equalTo(expectedValue) {
33
+ if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
34
+ this.limit = true;
26
35
  _setStrictType(this, `'${expectedValue}'`);
27
36
  return this.custom(equalTo(expectedValue));
28
37
  }
@@ -36,6 +45,8 @@ var StringSchema = class extends CommonSchema {
36
45
  * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
37
46
  */
38
47
  oneOfValues(expectedValue) {
48
+ if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
49
+ this.limit = true;
39
50
  _setStrictType(
40
51
  this,
41
52
  expectedValue.map((el) => `'${el}'`)
@@ -47,4 +58,4 @@ var StringSchema = class extends CommonSchema {
47
58
  export {
48
59
  StringSchema
49
60
  };
50
- //# sourceMappingURL=chunk-FTLRX2XG.mjs.map
61
+ //# sourceMappingURL=chunk-JPRCULRQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n private limit: boolean | undefined;\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 if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(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":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,IAAI,aAAa,GAAG;AAEzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
@@ -6,14 +6,21 @@ var _chunkJ4VKFJQKjs = require('./chunk-J4VKFJQK.js');
6
6
  var _chunk4CYIMDP2js = require('./chunk-4CYIMDP2.js');
7
7
 
8
8
 
9
+ var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
10
+
11
+
9
12
  var _chunkJSGZ7DKTjs = require('./chunk-JSGZ7DKT.js');
10
13
 
11
14
 
12
15
  var _chunkEGEHSELTjs = require('./chunk-EGEHSELT.js');
13
16
 
17
+
18
+ var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
19
+
14
20
  // src/schemas/NumberSchema.ts
15
21
  var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
16
22
  __init() {this._number = 1}
23
+
17
24
  /**
18
25
  * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
19
26
  *
@@ -23,6 +30,8 @@ var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
23
30
  * @example - number().equalTo(42); // Infers the type 42
24
31
  */
25
32
  equalTo(expectedValue) {
33
+ if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
34
+ this.limit = true;
26
35
  _chunkJSGZ7DKTjs._setStrictType.call(void 0, this, expectedValue);
27
36
  return this.custom(_chunkJ4VKFJQKjs.equalTo.call(void 0, expectedValue));
28
37
  }
@@ -36,6 +45,8 @@ var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
36
45
  * number().oneOfValues([5, 7]); // Infers the type 5 | 7
37
46
  */
38
47
  oneOfValues(expectedValue) {
48
+ if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
49
+ this.limit = true;
39
50
  _chunkJSGZ7DKTjs._setStrictType.call(void 0, this, expectedValue);
40
51
  return this.custom(_chunk4CYIMDP2js.oneOfValues.call(void 0, expectedValue));
41
52
  }
@@ -44,4 +55,4 @@ var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
44
55
 
45
56
 
46
57
  exports.NumberSchema = NumberSchema;
47
- //# sourceMappingURL=chunk-RQH4LXBW.js.map
58
+ //# sourceMappingURL=chunk-KQKJASVB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-KQKJASVB.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADYA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-KQKJASVB.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n private limit: boolean | undefined;\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 - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"]}
@@ -6,14 +6,21 @@ var _chunkJ4VKFJQKjs = require('./chunk-J4VKFJQK.js');
6
6
  var _chunk4CYIMDP2js = require('./chunk-4CYIMDP2.js');
7
7
 
8
8
 
9
+ var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
10
+
11
+
9
12
  var _chunkJSGZ7DKTjs = require('./chunk-JSGZ7DKT.js');
10
13
 
11
14
 
12
15
  var _chunkEGEHSELTjs = require('./chunk-EGEHSELT.js');
13
16
 
17
+
18
+ var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
19
+
14
20
  // src/schemas/StringSchema.ts
15
21
  var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
16
22
  __init() {this._string = 1}
23
+
17
24
  /**
18
25
  * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
19
26
  *
@@ -23,6 +30,8 @@ var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
23
30
  * @example - string().equalTo('hello'); // Infers the type 'hello'
24
31
  */
25
32
  equalTo(expectedValue) {
33
+ if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
34
+ this.limit = true;
26
35
  _chunkJSGZ7DKTjs._setStrictType.call(void 0, this, `'${expectedValue}'`);
27
36
  return this.custom(_chunkJ4VKFJQKjs.equalTo.call(void 0, expectedValue));
28
37
  }
@@ -36,6 +45,8 @@ var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
36
45
  * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
37
46
  */
38
47
  oneOfValues(expectedValue) {
48
+ if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
49
+ this.limit = true;
39
50
  _chunkJSGZ7DKTjs._setStrictType.call(void 0,
40
51
  this,
41
52
  expectedValue.map((el) => `'${el}'`)
@@ -47,4 +58,4 @@ var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
47
58
 
48
59
 
49
60
  exports.StringSchema = StringSchema;
50
- //# sourceMappingURL=chunk-F5MSBL33.js.map
61
+ //# sourceMappingURL=chunk-LEQCDD66.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-LEQCDD66.js","../src/schemas/StringSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,CAAG,CAAA;AAEzC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA;AAAA,MACE,IAAA;AAAA,MACA,aAAA,CAAc,GAAA,CAAI,CAAC,EAAA,EAAA,GAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG;AAAA,IACrC,CAAA;AACA,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADWA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-LEQCDD66.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n private limit: boolean | undefined;\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 if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(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"]}
@@ -4,16 +4,23 @@ import {
4
4
  import {
5
5
  oneOfValues
6
6
  } from "./chunk-3O4WCRC2.mjs";
7
+ import {
8
+ ONLY_ONCE
9
+ } from "./chunk-ASZW6XRM.mjs";
7
10
  import {
8
11
  _setStrictType
9
12
  } from "./chunk-RYVUYVEE.mjs";
10
13
  import {
11
14
  CommonSchema
12
15
  } from "./chunk-DPBE7TAQ.mjs";
16
+ import {
17
+ BuildSchemaError
18
+ } from "./chunk-7XFLH6R2.mjs";
13
19
 
14
20
  // src/schemas/NumberSchema.ts
15
21
  var NumberSchema = class extends CommonSchema {
16
22
  _number = 1;
23
+ limit;
17
24
  /**
18
25
  * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
19
26
  *
@@ -23,6 +30,8 @@ var NumberSchema = class extends CommonSchema {
23
30
  * @example - number().equalTo(42); // Infers the type 42
24
31
  */
25
32
  equalTo(expectedValue) {
33
+ if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
34
+ this.limit = true;
26
35
  _setStrictType(this, expectedValue);
27
36
  return this.custom(equalTo(expectedValue));
28
37
  }
@@ -36,6 +45,8 @@ var NumberSchema = class extends CommonSchema {
36
45
  * number().oneOfValues([5, 7]); // Infers the type 5 | 7
37
46
  */
38
47
  oneOfValues(expectedValue) {
48
+ if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
49
+ this.limit = true;
39
50
  _setStrictType(this, expectedValue);
40
51
  return this.custom(oneOfValues(expectedValue));
41
52
  }
@@ -44,4 +55,4 @@ var NumberSchema = class extends CommonSchema {
44
55
  export {
45
56
  NumberSchema
46
57
  };
47
- //# sourceMappingURL=chunk-CLG3QRZC.mjs.map
58
+ //# sourceMappingURL=chunk-P7IXNCJG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/NumberSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n private limit: boolean | undefined;\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 - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NumberSchema
3
- } from "./chunk-CLG3QRZC.mjs";
3
+ } from "./chunk-P7IXNCJG.mjs";
4
4
 
5
5
  // src/asserts/number/index.ts
6
6
  function number() {
@@ -10,4 +10,4 @@ function number() {
10
10
  export {
11
11
  number
12
12
  };
13
- //# sourceMappingURL=chunk-B6TFELXR.mjs.map
13
+ //# sourceMappingURL=chunk-PXBAS3GA.mjs.map
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkRQH4LXBWjs = require('./chunk-RQH4LXBW.js');
3
+ var _chunkKQKJASVBjs = require('./chunk-KQKJASVB.js');
4
4
 
5
5
  // src/asserts/number/index.ts
6
6
  function number() {
7
- return new (0, _chunkRQH4LXBWjs.NumberSchema)({ type: ["number"], requiredValidations: [] });
7
+ return new (0, _chunkKQKJASVBjs.NumberSchema)({ type: ["number"], requiredValidations: [] });
8
8
  }
9
9
 
10
10
 
11
11
 
12
12
  exports.number = number;
13
- //# sourceMappingURL=chunk-4RNK3I74.js.map
13
+ //# sourceMappingURL=chunk-RD6TBCPQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-4RNK3I74.js","../src/asserts/number/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-4RNK3I74.js","sourcesContent":[null,"import { NumberSchema } from '../../schemas/NumberSchema';\n\n/**\n * Creates a new schema for validating number values.\n *\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n *\n * @example\n * const schema = number();\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(schema, '42'); // Throws a validation error\n */\nexport function number(): NumberSchema {\n return new NumberSchema({ type: ['number'], requiredValidations: [] });\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-RD6TBCPQ.js","../src/asserts/number/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-RD6TBCPQ.js","sourcesContent":[null,"import { NumberSchema } from '../../schemas/NumberSchema';\n\n/**\n * Creates a new schema for validating number values.\n *\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n *\n * @example\n * const schema = number();\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(schema, '42'); // Throws a validation error\n */\nexport function number(): NumberSchema {\n return new NumberSchema({ type: ['number'], requiredValidations: [] });\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkF5MSBL33js = require('./chunk-F5MSBL33.js');
3
+ var _chunkLEQCDD66js = require('./chunk-LEQCDD66.js');
4
4
 
5
5
  // src/asserts/string/index.ts
6
6
  function string() {
7
- return new (0, _chunkF5MSBL33js.StringSchema)({ type: ["string"], requiredValidations: [] });
7
+ return new (0, _chunkLEQCDD66js.StringSchema)({ type: ["string"], requiredValidations: [] });
8
8
  }
9
9
 
10
10
 
11
11
 
12
12
  exports.string = string;
13
- //# sourceMappingURL=chunk-RL4MSI7R.js.map
13
+ //# sourceMappingURL=chunk-TKZ6FLLR.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-RL4MSI7R.js","../src/asserts/string/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-RL4MSI7R.js","sourcesContent":[null,"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 * parseOrFail(schema, 'hello'); // Validates successfully\n * parseOrFail(schema, 123); // Throws a validation error\n */\nexport function string(): StringSchema {\n return new StringSchema({ type: ['string'], requiredValidations: [] });\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-TKZ6FLLR.js","../src/asserts/string/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-TKZ6FLLR.js","sourcesContent":[null,"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 * parseOrFail(schema, 'hello'); // Validates successfully\n * parseOrFail(schema, 123); // Throws a validation error\n */\nexport function string(): StringSchema {\n return new StringSchema({ type: ['string'], requiredValidations: [] });\n}\n"]}
@@ -0,0 +1,3 @@
1
+ declare const ONLY_ONCE = "It is allowed to call either 'equalTo' or 'oneOfValues,' but only one of them, and only once.";
2
+
3
+ export { ONLY_ONCE };
@@ -0,0 +1,3 @@
1
+ declare const ONLY_ONCE = "It is allowed to call either 'equalTo' or 'oneOfValues,' but only one of them, and only once.";
2
+
3
+ export { ONLY_ONCE };
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk42J6CHIOjs = require('../chunk-42J6CHIO.js');
4
+
5
+
6
+ exports.ONLY_ONCE = _chunk42J6CHIOjs.ONLY_ONCE;
7
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/helpers/constants.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B;AACE;AACF,+CAAC","file":"/home/runner/work/bguard/bguard/lib/helpers/constants.js"}
@@ -0,0 +1,7 @@
1
+ import {
2
+ ONLY_ONCE
3
+ } from "../chunk-ASZW6XRM.mjs";
4
+ export {
5
+ ONLY_ONCE
6
+ };
7
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/lib/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkVHEA4JZ5js = require('./chunk-VHEA4JZ5.js');
3
+ var _chunkTKZ6FLLRjs = require('./chunk-TKZ6FLLR.js');
4
4
 
5
5
 
6
- var _chunkRL4MSI7Rjs = require('./chunk-RL4MSI7R.js');
6
+ var _chunkVHEA4JZ5js = require('./chunk-VHEA4JZ5.js');
7
+ require('./chunk-LEQCDD66.js');
7
8
 
8
9
 
9
10
  var _chunkIEUXIOL6js = require('./chunk-IEUXIOL6.js');
@@ -15,15 +16,15 @@ var _chunkHDSGCAHHjs = require('./chunk-HDSGCAHH.js');
15
16
  var _chunkQQNQ4IDNjs = require('./chunk-QQNQ4IDN.js');
16
17
 
17
18
 
18
- var _chunk4RNK3I74js = require('./chunk-4RNK3I74.js');
19
+ var _chunkRD6TBCPQjs = require('./chunk-RD6TBCPQ.js');
19
20
  require('./chunk-RRQOET3X.js');
20
21
  require('./chunk-WBERBAL4.js');
21
- require('./chunk-RQH4LXBW.js');
22
- require('./chunk-6TH3DBDK.js');
23
- require('./chunk-F5MSBL33.js');
22
+ require('./chunk-KQKJASVB.js');
24
23
  require('./chunk-J4VKFJQK.js');
25
24
  require('./chunk-4CYIMDP2.js');
25
+ require('./chunk-42J6CHIO.js');
26
26
  require('./chunk-JSGZ7DKT.js');
27
+ require('./chunk-6TH3DBDK.js');
27
28
  require('./chunk-EGEHSELT.js');
28
29
 
29
30
 
@@ -57,5 +58,5 @@ var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
57
58
 
58
59
 
59
60
 
60
- exports.BuildSchemaError = _chunkWK4O3HH4js.BuildSchemaError; exports.ValidationError = _chunkWK4O3HH4js.ValidationError; exports.array = _chunkIEUXIOL6js.array; exports.boolean = _chunkHDSGCAHHjs.boolean; exports.clearLocales = _chunk5BVJ6YMHjs.clearLocales; exports.guardException = _chunkWK4O3HH4js.guardException; exports.number = _chunk4RNK3I74js.number; exports.object = _chunkVHEA4JZ5js.object; exports.oneOfTypes = _chunkQQNQ4IDNjs.oneOfTypes; exports.parse = _chunkH7CPKW53js.parse; exports.parseOrFail = _chunkDJSLA2ZVjs.parseOrFail; exports.setLocale = _chunk5BVJ6YMHjs.setLocale; exports.setToDefaultLocale = _chunk5BVJ6YMHjs.setToDefaultLocale; exports.string = _chunkRL4MSI7Rjs.string;
61
+ exports.BuildSchemaError = _chunkWK4O3HH4js.BuildSchemaError; exports.ValidationError = _chunkWK4O3HH4js.ValidationError; exports.array = _chunkIEUXIOL6js.array; exports.boolean = _chunkHDSGCAHHjs.boolean; exports.clearLocales = _chunk5BVJ6YMHjs.clearLocales; exports.guardException = _chunkWK4O3HH4js.guardException; exports.number = _chunkRD6TBCPQjs.number; exports.object = _chunkVHEA4JZ5js.object; exports.oneOfTypes = _chunkQQNQ4IDNjs.oneOfTypes; exports.parse = _chunkH7CPKW53js.parse; exports.parseOrFail = _chunkDJSLA2ZVjs.parseOrFail; exports.setLocale = _chunk5BVJ6YMHjs.setLocale; exports.setToDefaultLocale = _chunk5BVJ6YMHjs.setToDefaultLocale; exports.string = _chunkTKZ6FLLRjs.string;
61
62
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2rBAAC","file":"/home/runner/work/bguard/bguard/lib/index.js"}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2rBAAC","file":"/home/runner/work/bguard/bguard/lib/index.js"}
package/lib/index.mjs CHANGED
@@ -1,9 +1,10 @@
1
+ import {
2
+ string
3
+ } from "./chunk-32RSTOZ4.mjs";
1
4
  import {
2
5
  object
3
6
  } from "./chunk-2PM3K3OE.mjs";
4
- import {
5
- string
6
- } from "./chunk-NTC2XQ36.mjs";
7
+ import "./chunk-JPRCULRQ.mjs";
7
8
  import {
8
9
  array
9
10
  } from "./chunk-JDGZCBXF.mjs";
@@ -15,15 +16,15 @@ import {
15
16
  } from "./chunk-MRISXZQ4.mjs";
16
17
  import {
17
18
  number
18
- } from "./chunk-B6TFELXR.mjs";
19
+ } from "./chunk-PXBAS3GA.mjs";
19
20
  import "./chunk-NDQM5OL4.mjs";
20
21
  import "./chunk-CCBCDJXS.mjs";
21
- import "./chunk-CLG3QRZC.mjs";
22
- import "./chunk-TCQY2R3U.mjs";
23
- import "./chunk-FTLRX2XG.mjs";
22
+ import "./chunk-P7IXNCJG.mjs";
24
23
  import "./chunk-NNFYXHLU.mjs";
25
24
  import "./chunk-3O4WCRC2.mjs";
25
+ import "./chunk-ASZW6XRM.mjs";
26
26
  import "./chunk-RYVUYVEE.mjs";
27
+ import "./chunk-TCQY2R3U.mjs";
27
28
  import "./chunk-DPBE7TAQ.mjs";
28
29
  import {
29
30
  parse
@@ -3,6 +3,7 @@ import '../commonTypes.mjs';
3
3
 
4
4
  declare class NumberSchema extends CommonSchema {
5
5
  _number: number;
6
+ private limit;
6
7
  /**
7
8
  * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
8
9
  *
@@ -3,6 +3,7 @@ import '../commonTypes.js';
3
3
 
4
4
  declare class NumberSchema extends CommonSchema {
5
5
  _number: number;
6
+ private limit;
6
7
  /**
7
8
  * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
8
9
  *
@@ -1,8 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkRQH4LXBWjs = require('../chunk-RQH4LXBW.js');
3
+ var _chunkKQKJASVBjs = require('../chunk-KQKJASVB.js');
4
4
  require('../chunk-J4VKFJQK.js');
5
5
  require('../chunk-4CYIMDP2.js');
6
+ require('../chunk-42J6CHIO.js');
6
7
  require('../chunk-JSGZ7DKT.js');
7
8
  require('../chunk-EGEHSELT.js');
8
9
  require('../chunk-IRG4OQAB.js');
@@ -10,5 +11,5 @@ require('../chunk-5BVJ6YMH.js');
10
11
  require('../chunk-WK4O3HH4.js');
11
12
 
12
13
 
13
- exports.NumberSchema = _chunkRQH4LXBWjs.NumberSchema;
14
+ exports.NumberSchema = _chunkKQKJASVBjs.NumberSchema;
14
15
  //# sourceMappingURL=NumberSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/schemas/NumberSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/schemas/NumberSchema.js"}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/schemas/NumberSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/schemas/NumberSchema.js"}
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  NumberSchema
3
- } from "../chunk-CLG3QRZC.mjs";
3
+ } from "../chunk-P7IXNCJG.mjs";
4
4
  import "../chunk-NNFYXHLU.mjs";
5
5
  import "../chunk-3O4WCRC2.mjs";
6
+ import "../chunk-ASZW6XRM.mjs";
6
7
  import "../chunk-RYVUYVEE.mjs";
7
8
  import "../chunk-DPBE7TAQ.mjs";
8
9
  import "../chunk-PH2PMUZP.mjs";
@@ -3,6 +3,7 @@ import '../commonTypes.mjs';
3
3
 
4
4
  declare class StringSchema extends CommonSchema {
5
5
  _string: number;
6
+ private limit;
6
7
  /**
7
8
  * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
8
9
  *
@@ -3,6 +3,7 @@ import '../commonTypes.js';
3
3
 
4
4
  declare class StringSchema extends CommonSchema {
5
5
  _string: number;
6
+ private limit;
6
7
  /**
7
8
  * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
8
9
  *
@@ -1,8 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkF5MSBL33js = require('../chunk-F5MSBL33.js');
3
+ var _chunkLEQCDD66js = require('../chunk-LEQCDD66.js');
4
4
  require('../chunk-J4VKFJQK.js');
5
5
  require('../chunk-4CYIMDP2.js');
6
+ require('../chunk-42J6CHIO.js');
6
7
  require('../chunk-JSGZ7DKT.js');
7
8
  require('../chunk-EGEHSELT.js');
8
9
  require('../chunk-IRG4OQAB.js');
@@ -10,5 +11,5 @@ require('../chunk-5BVJ6YMH.js');
10
11
  require('../chunk-WK4O3HH4.js');
11
12
 
12
13
 
13
- exports.StringSchema = _chunkF5MSBL33js.StringSchema;
14
+ exports.StringSchema = _chunkLEQCDD66js.StringSchema;
14
15
  //# sourceMappingURL=StringSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/schemas/StringSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/schemas/StringSchema.js"}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/schemas/StringSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/schemas/StringSchema.js"}
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  StringSchema
3
- } from "../chunk-FTLRX2XG.mjs";
3
+ } from "../chunk-JPRCULRQ.mjs";
4
4
  import "../chunk-NNFYXHLU.mjs";
5
5
  import "../chunk-3O4WCRC2.mjs";
6
+ import "../chunk-ASZW6XRM.mjs";
6
7
  import "../chunk-RYVUYVEE.mjs";
7
8
  import "../chunk-DPBE7TAQ.mjs";
8
9
  import "../chunk-PH2PMUZP.mjs";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "bguard",
3
3
  "private": false,
4
4
  "license": "MIT",
5
- "version": "0.1.0",
5
+ "version": "0.1.1",
6
6
  "main": "lib/index.js",
7
7
  "module": "lib/index.mjs",
8
8
  "types": "lib/index.d.ts",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/NumberSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 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 - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;AAKO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,QAA0B,eAAuC;AAC/D,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-F5MSBL33.js","../src/schemas/StringSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACRO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,6CAAA,IAAe,EAAM,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,CAAG,CAAA;AACzC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,6CAAA;AAAA,MACE,IAAA;AAAA,MACA,aAAA,CAAc,GAAA,CAAI,CAAC,EAAA,EAAA,GAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG;AAAA,IACrC,CAAA;AACA,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADQA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-F5MSBL33.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { _setStrictType } from '../helpers/setStrictType';\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 _setStrictType(this, `'${expectedValue}'`);\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { _setStrictType } from '../helpers/setStrictType';\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 _setStrictType(this, `'${expectedValue}'`);\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(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":";;;;;;;;;;;;;;AAKO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,QAA0B,eAAuC;AAC/D,mBAAe,MAAM,IAAI,aAAa,GAAG;AACzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-RQH4LXBW.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACRO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADQA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-RQH4LXBW.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 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 - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"]}