bguard 0.0.4 → 0.0.5

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 (148) 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 +19 -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/__tests__/ArraySchema.test.d.mts +2 -0
  10. package/lib/__tests__/ArraySchema.test.d.ts +2 -0
  11. package/lib/__tests__/ArraySchema.test.js +201 -0
  12. package/lib/__tests__/ArraySchema.test.js.map +1 -0
  13. package/lib/__tests__/ArraySchema.test.mjs +199 -0
  14. package/lib/__tests__/ArraySchema.test.mjs.map +1 -0
  15. package/lib/__tests__/BooleanSchema.test.d.mts +2 -0
  16. package/lib/__tests__/BooleanSchema.test.d.ts +2 -0
  17. package/lib/__tests__/BooleanSchema.test.js +219 -0
  18. package/lib/__tests__/BooleanSchema.test.js.map +1 -0
  19. package/lib/__tests__/BooleanSchema.test.mjs +217 -0
  20. package/lib/__tests__/BooleanSchema.test.mjs.map +1 -0
  21. package/lib/__tests__/CommonSchema.test.d.mts +2 -0
  22. package/lib/__tests__/CommonSchema.test.d.ts +2 -0
  23. package/lib/__tests__/CommonSchema.test.js +253 -0
  24. package/lib/__tests__/CommonSchema.test.js.map +1 -0
  25. package/lib/__tests__/CommonSchema.test.mjs +251 -0
  26. package/lib/__tests__/CommonSchema.test.mjs.map +1 -0
  27. package/lib/__tests__/MixTypes.test.d.mts +2 -0
  28. package/lib/__tests__/MixTypes.test.d.ts +2 -0
  29. package/lib/__tests__/MixTypes.test.js +165 -0
  30. package/lib/__tests__/MixTypes.test.js.map +1 -0
  31. package/lib/__tests__/MixTypes.test.mjs +163 -0
  32. package/lib/__tests__/MixTypes.test.mjs.map +1 -0
  33. package/lib/__tests__/NumberSchema.test.d.mts +2 -0
  34. package/lib/__tests__/NumberSchema.test.d.ts +2 -0
  35. package/lib/__tests__/NumberSchema.test.js +253 -0
  36. package/lib/__tests__/NumberSchema.test.js.map +1 -0
  37. package/lib/__tests__/NumberSchema.test.mjs +251 -0
  38. package/lib/__tests__/NumberSchema.test.mjs.map +1 -0
  39. package/lib/__tests__/ObjectSchema.test.d.mts +2 -0
  40. package/lib/__tests__/ObjectSchema.test.d.ts +2 -0
  41. package/lib/__tests__/ObjectSchema.test.js +356 -0
  42. package/lib/__tests__/ObjectSchema.test.js.map +1 -0
  43. package/lib/__tests__/ObjectSchema.test.mjs +354 -0
  44. package/lib/__tests__/ObjectSchema.test.mjs.map +1 -0
  45. package/lib/__tests__/StringSchema.test.d.mts +2 -0
  46. package/lib/__tests__/StringSchema.test.d.ts +2 -0
  47. package/lib/__tests__/StringSchema.test.js +228 -0
  48. package/lib/__tests__/StringSchema.test.js.map +1 -0
  49. package/lib/__tests__/StringSchema.test.mjs +226 -0
  50. package/lib/__tests__/StringSchema.test.mjs.map +1 -0
  51. package/lib/asserts/array/index.d.mts +18 -2
  52. package/lib/asserts/array/index.d.ts +18 -2
  53. package/lib/asserts/boolean/index.d.mts +16 -2
  54. package/lib/asserts/boolean/index.d.ts +16 -2
  55. package/lib/asserts/common/equalTo.d.mts +1 -1
  56. package/lib/asserts/common/equalTo.d.ts +1 -1
  57. package/lib/asserts/common/index.d.mts +1 -1
  58. package/lib/asserts/common/index.d.ts +1 -1
  59. package/lib/asserts/number/index.d.mts +16 -2
  60. package/lib/asserts/number/index.d.ts +16 -2
  61. package/lib/asserts/number/max.d.mts +1 -1
  62. package/lib/asserts/number/max.d.ts +1 -1
  63. package/lib/asserts/number/maxExcluded.d.mts +1 -1
  64. package/lib/asserts/number/maxExcluded.d.ts +1 -1
  65. package/lib/asserts/number/min.d.mts +1 -1
  66. package/lib/asserts/number/min.d.ts +1 -1
  67. package/lib/asserts/number/minExcluded.d.mts +1 -1
  68. package/lib/asserts/number/minExcluded.d.ts +1 -1
  69. package/lib/asserts/number/negative.d.mts +1 -1
  70. package/lib/asserts/number/negative.d.ts +1 -1
  71. package/lib/asserts/number/positive.d.mts +1 -1
  72. package/lib/asserts/number/positive.d.ts +1 -1
  73. package/lib/asserts/object/index.d.mts +21 -2
  74. package/lib/asserts/object/index.d.ts +21 -2
  75. package/lib/asserts/string/email.d.mts +1 -1
  76. package/lib/asserts/string/email.d.ts +1 -1
  77. package/lib/asserts/string/index.d.mts +16 -2
  78. package/lib/asserts/string/index.d.ts +16 -2
  79. package/lib/asserts/string/maxLength.d.mts +1 -1
  80. package/lib/asserts/string/maxLength.d.ts +1 -1
  81. package/lib/asserts/string/minLength.d.mts +1 -1
  82. package/lib/asserts/string/minLength.d.ts +1 -1
  83. package/lib/asserts/string/regExp.d.mts +1 -1
  84. package/lib/asserts/string/regExp.d.ts +1 -1
  85. package/lib/core.d.mts +1 -0
  86. package/lib/core.d.ts +1 -0
  87. package/lib/core.js +111 -0
  88. package/lib/core.js.map +1 -0
  89. package/lib/core.mjs +83 -0
  90. package/lib/core.mjs.map +1 -0
  91. package/lib/exceptions.d.mts +12 -0
  92. package/lib/exceptions.d.ts +12 -0
  93. package/lib/exceptions.js +52 -0
  94. package/lib/exceptions.js.map +1 -0
  95. package/lib/exceptions.mjs +25 -0
  96. package/lib/exceptions.mjs.map +1 -0
  97. package/lib/index.d.mts +14 -51
  98. package/lib/index.d.ts +14 -51
  99. package/lib/index.js +8 -2
  100. package/lib/index.js.map +1 -1
  101. package/lib/index.mjs +4 -1
  102. package/lib/parseSchema.d.mts +37 -0
  103. package/lib/parseSchema.d.ts +37 -0
  104. package/lib/parseSchema.js +119 -0
  105. package/lib/parseSchema.js.map +1 -0
  106. package/lib/parseSchema.mjs +92 -0
  107. package/lib/parseSchema.mjs.map +1 -0
  108. package/lib/schemas/ArraySchema.d.mts +13 -0
  109. package/lib/schemas/ArraySchema.d.ts +13 -0
  110. package/lib/schemas/ArraySchema.js +85 -0
  111. package/lib/schemas/ArraySchema.js.map +1 -0
  112. package/lib/schemas/ArraySchema.mjs +58 -0
  113. package/lib/schemas/ArraySchema.mjs.map +1 -0
  114. package/lib/{index-nzqBrOHf.d.mts → schemas/BooleanSchema.d.mts} +2 -14
  115. package/lib/{index-B1yBez0g.d.ts → schemas/BooleanSchema.d.ts} +2 -14
  116. package/lib/schemas/BooleanSchema.js +113 -0
  117. package/lib/schemas/BooleanSchema.js.map +1 -0
  118. package/lib/schemas/BooleanSchema.mjs +86 -0
  119. package/lib/schemas/BooleanSchema.mjs.map +1 -0
  120. package/lib/schemas/CommonSchema.d.mts +1 -0
  121. package/lib/schemas/CommonSchema.d.ts +1 -0
  122. package/lib/schemas/CommonSchema.js +67 -0
  123. package/lib/schemas/CommonSchema.js.map +1 -0
  124. package/lib/schemas/CommonSchema.mjs +40 -0
  125. package/lib/schemas/CommonSchema.mjs.map +1 -0
  126. package/lib/{index-B63cXDOm.d.mts → schemas/NumberSchema.d.mts} +2 -14
  127. package/lib/{index-CK_g_aEC.d.ts → schemas/NumberSchema.d.ts} +2 -14
  128. package/lib/schemas/NumberSchema.js +107 -0
  129. package/lib/schemas/NumberSchema.js.map +1 -0
  130. package/lib/schemas/NumberSchema.mjs +80 -0
  131. package/lib/schemas/NumberSchema.mjs.map +1 -0
  132. package/lib/schemas/ObjectSchema.d.mts +12 -0
  133. package/lib/schemas/ObjectSchema.d.ts +12 -0
  134. package/lib/schemas/ObjectSchema.js +89 -0
  135. package/lib/schemas/ObjectSchema.js.map +1 -0
  136. package/lib/schemas/ObjectSchema.mjs +62 -0
  137. package/lib/schemas/ObjectSchema.mjs.map +1 -0
  138. package/lib/{index-aBEYpJdZ.d.mts → schemas/StringSchema.d.mts} +2 -14
  139. package/lib/{index-BEyBEBSm.d.ts → schemas/StringSchema.d.ts} +2 -14
  140. package/lib/schemas/StringSchema.js +107 -0
  141. package/lib/schemas/StringSchema.js.map +1 -0
  142. package/lib/schemas/StringSchema.mjs +80 -0
  143. package/lib/schemas/StringSchema.mjs.map +1 -0
  144. package/package.json +28 -27
  145. package/lib/index-D3R2euaT.d.mts +0 -29
  146. package/lib/index-DPkImfCy.d.ts +0 -29
  147. package/lib/index-DitgsWDO.d.ts +0 -27
  148. package/lib/index-T3KBmyyn.d.mts +0 -27
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+
3
+ // jest/setup.ts
4
+ function expectEqualTypes(areEqual) {
5
+ expect(typeof areEqual).toBe("boolean");
6
+ }
7
+
8
+ // src/exceptions.ts
9
+ var ValidationError = class extends Error {
10
+ expected;
11
+ received;
12
+ pathToError;
13
+ message;
14
+ constructor(expected, received, pathToError, message) {
15
+ super();
16
+ this.expected = expected;
17
+ this.received = received;
18
+ this.pathToError = pathToError;
19
+ this.message = message;
20
+ }
21
+ };
22
+ function throwException(expected, received, pathToError, message) {
23
+ throw new ValidationError(expected, received, pathToError, message);
24
+ }
25
+
26
+ // src/core.ts
27
+ var ctxSymbol = Symbol("contextSymbol");
28
+ function innerCheck(schema, receivedValue, pathToError) {
29
+ const ctx = schema[ctxSymbol];
30
+ if (receivedValue === void 0) {
31
+ if (!ctx.isOptional) throwException("Required", receivedValue, pathToError, "The required value is missing");
32
+ return receivedValue;
33
+ }
34
+ if (receivedValue === null) {
35
+ if (!ctx.isNullable) throwException("Not null", receivedValue, pathToError, "Value should not be null");
36
+ return receivedValue;
37
+ }
38
+ if (ctx.array) {
39
+ if (!Array.isArray(receivedValue))
40
+ throwException("Array", receivedValue, pathToError, "Expected an array but received a different type");
41
+ const schema2 = ctx.array;
42
+ receivedValue.forEach((elem, i) => {
43
+ innerCheck(schema2, elem, `${pathToError}[${i}]`);
44
+ });
45
+ return receivedValue;
46
+ }
47
+ const typeOfVal = typeof receivedValue;
48
+ if (ctx.object) {
49
+ if (typeOfVal !== "object")
50
+ throwException("Object", receivedValue, pathToError, "Expected an object but received a different type");
51
+ if (Array.isArray(receivedValue))
52
+ throwException(
53
+ "Object",
54
+ receivedValue,
55
+ pathToError,
56
+ "Expected an object but received an array. Invalid type of data"
57
+ );
58
+ const shapeSchema = ctx.object;
59
+ for (const keyPerReceivedValue of Object.keys(receivedValue)) {
60
+ if (shapeSchema[keyPerReceivedValue] === void 0)
61
+ throwException("Not allowed", keyPerReceivedValue, pathToError, "This key is not allowed in the object");
62
+ }
63
+ for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {
64
+ const receivedObjectValuePropery = receivedValue[keyOfSchema];
65
+ if (receivedObjectValuePropery === void 0) {
66
+ if (!valueOfSchema[ctxSymbol].isOptional)
67
+ throwException(
68
+ "Required",
69
+ receivedObjectValuePropery,
70
+ pathToError,
71
+ "Missing required property in the object"
72
+ );
73
+ }
74
+ innerCheck(valueOfSchema, receivedObjectValuePropery, `${pathToError}.${keyOfSchema}`);
75
+ }
76
+ return receivedValue;
77
+ }
78
+ if (ctx.type.length) {
79
+ if (!ctx.type.includes(typeOfVal)) throwException(ctx.type, typeOfVal, pathToError, "Invalid type of data");
80
+ }
81
+ ctx.requiredValidations.forEach((requiredValidation) => {
82
+ requiredValidation(receivedValue, pathToError);
83
+ });
84
+ return receivedValue;
85
+ }
86
+
87
+ // src/parseSchema.ts
88
+ function parseSchema(schema, receivedValue) {
89
+ try {
90
+ return innerCheck(schema, receivedValue, "");
91
+ } catch (e) {
92
+ if (e instanceof ValidationError) throw e;
93
+ throw new Error("Something unexpected happened");
94
+ }
95
+ }
96
+
97
+ // src/schemas/CommonSchema.ts
98
+ var CommonSchema = class {
99
+ [ctxSymbol];
100
+ constructor(ctx) {
101
+ this[ctxSymbol] = ctx;
102
+ }
103
+ /**
104
+ * @param validators - One or more custom validation functions.
105
+ * @returns {this} The schema instance with the added custom validation.
106
+ */
107
+ custom(...validators) {
108
+ this[ctxSymbol].requiredValidations.push(...validators);
109
+ return this;
110
+ }
111
+ /**
112
+ * Marks the schema as nullable, allowing the value to be `null`.
113
+ *
114
+ * @returns {WithNull<this>} The schema instance marked as nullable.
115
+ */
116
+ nullable() {
117
+ this[ctxSymbol].isNullable = true;
118
+ return this;
119
+ }
120
+ /**
121
+ * Marks the schema as optional, allowing the value to be `undefined`.
122
+ *
123
+ * @returns {WithUndefined<this>}} The schema instance marked as optional.
124
+ */
125
+ optional() {
126
+ this[ctxSymbol].isOptional = true;
127
+ return this;
128
+ }
129
+ };
130
+
131
+ // src/schemas/BooleanSchema.ts
132
+ var isBoolean = (expected) => (received, pathToError) => {
133
+ if (received !== expected) throwException(expected, received, pathToError, `The received value is not ${expected}`);
134
+ };
135
+ var BooleanSchema = class extends CommonSchema {
136
+ _boolean = 1;
137
+ /**
138
+ * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.
139
+ *
140
+ * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type
141
+ *
142
+ * @example - boolean().onlyTrue(); // Infers the type true
143
+ */
144
+ onlyTrue() {
145
+ return this.custom(isBoolean(true));
146
+ }
147
+ /**
148
+ * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.
149
+ *
150
+ * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type
151
+ *
152
+ * @example - boolean().onlyFalse(); // Infers the type false
153
+ */
154
+ onlyFalse() {
155
+ return this.custom(isBoolean(false));
156
+ }
157
+ };
158
+
159
+ // src/asserts/boolean/index.ts
160
+ function boolean() {
161
+ return new BooleanSchema({ type: ["boolean"], requiredValidations: [] });
162
+ }
163
+
164
+ // src/__tests__/BooleanSchema.test.ts
165
+ describe("BooleanSchema", () => {
166
+ it("should be a boolean", () => {
167
+ const booleanSchema = boolean();
168
+ expectEqualTypes(true);
169
+ expect(parseSchema(booleanSchema, true)).toBe(true);
170
+ expect(parseSchema(booleanSchema, false)).toBe(false);
171
+ });
172
+ it("should not be a boolean", () => {
173
+ const booleanSchema = boolean();
174
+ const actualNotBoolean = 9;
175
+ expectEqualTypes(false);
176
+ expect(() => parseSchema(booleanSchema, actualNotBoolean)).toThrow("Invalid type of data");
177
+ });
178
+ it("should be true", () => {
179
+ const booleanSchema = boolean().onlyTrue();
180
+ expectEqualTypes(true);
181
+ expectEqualTypes(false);
182
+ expect(parseSchema(booleanSchema, true)).toBe(true);
183
+ expect(() => parseSchema(booleanSchema, false)).toThrow("The received value is not true");
184
+ });
185
+ it("should be false", () => {
186
+ const booleanSchema = boolean().onlyFalse();
187
+ expectEqualTypes(true);
188
+ expectEqualTypes(false);
189
+ expect(parseSchema(booleanSchema, false)).toBe(false);
190
+ expect(() => parseSchema(booleanSchema, true)).toThrow("The received value is not false");
191
+ });
192
+ it("should have proper types", () => {
193
+ const booleanSchema = boolean();
194
+ const booleanOrNullSchema = boolean().nullable();
195
+ const booleanOrUndefinedSchema = boolean().optional();
196
+ const booleanOrNullOrUndefinedSchema = boolean().nullable().optional();
197
+ expectEqualTypes(true);
198
+ expectEqualTypes(true);
199
+ expectEqualTypes(true);
200
+ expectEqualTypes(true);
201
+ const falseSchema = boolean().onlyFalse();
202
+ const falseOrNullSchema = boolean().onlyFalse().nullable();
203
+ const falseOrUndefinedSchema = boolean().onlyFalse().optional();
204
+ const falseOrNullOrUndefinedSchema = boolean().onlyFalse().nullable().optional();
205
+ expectEqualTypes(true);
206
+ expectEqualTypes(true);
207
+ expectEqualTypes(true);
208
+ expectEqualTypes(true);
209
+ const trueSchema = boolean().onlyTrue();
210
+ const trueOrNullSchema = boolean().onlyTrue().nullable();
211
+ const trueOrUndefinedSchema = boolean().onlyTrue().optional();
212
+ const trueOrNullOrUndefinedSchema = boolean().onlyTrue().nullable().optional();
213
+ expectEqualTypes(true);
214
+ expectEqualTypes(true);
215
+ expectEqualTypes(true);
216
+ expectEqualTypes(true);
217
+ });
218
+ });
219
+ //# sourceMappingURL=BooleanSchema.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../jest/setup.ts","../../src/exceptions.ts","../../src/core.ts","../../src/parseSchema.ts","../../src/schemas/CommonSchema.ts","../../src/schemas/BooleanSchema.ts","../../src/asserts/boolean/index.ts","../../src/__tests__/BooleanSchema.test.ts"],"sourcesContent":["export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;\n\nexport function expectEqualTypes<X, Y>(areEqual: Equal<X, Y>): void {\n expect(typeof areEqual).toBe('boolean');\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","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 { InferType } from './InferType';\nimport { innerCheck } from './core';\nimport { ValidationError } from './exceptions';\nimport { CommonSchema } from './schemas/CommonSchema';\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe result.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @returns {InferType<T>} The validated value, with its TypeScript type inferred from the schema.\n *\n * @throws {ValidationError} If the received value does not match the schema, a `ValidationError` will be thrown.\n * @throws {Error} If an unexpected error occurs during validation, an error will be thrown with a generic message.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const result = parseSchema(schema, { name: 'Alice', age: 30 });\n * // result will be inferred as { name: string; age: number }\n *\n * parseSchema(schema, { name: 'Alice', age: '30' });\n * // Throws ValidationError because 'age' should be a number, not a string.\n */\nexport function parseSchema<T extends CommonSchema>(schema: T, receivedValue: unknown): InferType<T> {\n try {\n return innerCheck(schema, receivedValue, '') as InferType<T>;\n } catch (e) {\n if (e instanceof ValidationError) throw e;\n /* istanbul ignore next */\n throw new Error('Something unexpected happened');\n }\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 { CommonSchema } from './CommonSchema';\nimport { throwException } from '../exceptions';\n\nconst isBoolean = (expected: boolean) => (received: boolean, pathToError: string) => {\n if (received !== expected) throwException(expected, received, pathToError, `The received value is not ${expected}`);\n};\n\nexport class BooleanSchema extends CommonSchema {\n _boolean = 1;\n\n /**\n * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type\n *\n * @example - boolean().onlyTrue(); // Infers the type true\n */\n onlyTrue(): WithBoolean<this, true> {\n return this.custom(isBoolean(true)) as WithBoolean<this, true>;\n }\n\n /**\n * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type\n *\n * @example - boolean().onlyFalse(); // Infers the type false\n */\n onlyFalse(): WithBoolean<this, false> {\n return this.custom(isBoolean(false)) as WithBoolean<this, false>;\n }\n}\n\nexport type WithBoolean<T extends BooleanSchema, Y = boolean> = T & { validation_boolean: Y };\nexport type ExtractFromBoolean<T> = T extends WithBoolean<BooleanSchema, infer Y> ? Y : never;\n","import { BooleanSchema } from '../../schemas/BooleanSchema';\n\n/**\n * Creates a new schema for validating boolean values.\n *\n * @returns {BooleanSchema} A new instance of `BooleanSchema` for validating booleans.\n *\n * @example\n * const schema = boolean();\n * parseSchema(schema, true); // Validates successfully\n * parseSchema(schema, 'true'); // Throws a validation error\n */\nexport function boolean(): BooleanSchema {\n return new BooleanSchema({ type: ['boolean'], requiredValidations: [] });\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { expectEqualTypes } from '../../jest/setup';\nimport { parseSchema } from '../parseSchema';\nimport { InferType } from '../InferType';\nimport { boolean } from '../asserts/boolean';\n\ndescribe('BooleanSchema', () => {\n it('should be a boolean', () => {\n const booleanSchema = boolean();\n expectEqualTypes<boolean, InferType<typeof booleanSchema>>(true);\n expect(parseSchema(booleanSchema, true)).toBe(true);\n expect(parseSchema(booleanSchema, false)).toBe(false);\n });\n\n it('should not be a boolean', () => {\n const booleanSchema = boolean();\n // eslint-disable-next-line @typescript-eslint/no-inferrable-types\n const actualNotBoolean: number = 9;\n\n expectEqualTypes<typeof actualNotBoolean, InferType<typeof booleanSchema>>(false);\n expect(() => parseSchema(booleanSchema, actualNotBoolean)).toThrow('Invalid type of data');\n });\n\n it('should be true', () => {\n const booleanSchema = boolean().onlyTrue();\n\n expectEqualTypes<true, InferType<typeof booleanSchema>>(true);\n expectEqualTypes<boolean, InferType<typeof booleanSchema>>(false);\n expect(parseSchema(booleanSchema, true)).toBe(true);\n expect(() => parseSchema(booleanSchema, false)).toThrow('The received value is not true');\n });\n\n it('should be false', () => {\n const booleanSchema = boolean().onlyFalse();\n\n expectEqualTypes<false, InferType<typeof booleanSchema>>(true);\n expectEqualTypes<boolean, InferType<typeof booleanSchema>>(false);\n expect(parseSchema(booleanSchema, false)).toBe(false);\n expect(() => parseSchema(booleanSchema, true)).toThrow('The received value is not false');\n });\n\n it('should have proper types', () => {\n const booleanSchema = boolean();\n const booleanOrNullSchema = boolean().nullable();\n const booleanOrUndefinedSchema = boolean().optional();\n const booleanOrNullOrUndefinedSchema = boolean().nullable().optional();\n\n expectEqualTypes<boolean, InferType<typeof booleanSchema>>(true);\n expectEqualTypes<boolean | null, InferType<typeof booleanOrNullSchema>>(true);\n expectEqualTypes<boolean | undefined, InferType<typeof booleanOrUndefinedSchema>>(true);\n expectEqualTypes<boolean | null | undefined, InferType<typeof booleanOrNullOrUndefinedSchema>>(true);\n\n const falseSchema = boolean().onlyFalse();\n const falseOrNullSchema = boolean().onlyFalse().nullable();\n const falseOrUndefinedSchema = boolean().onlyFalse().optional();\n const falseOrNullOrUndefinedSchema = boolean().onlyFalse().nullable().optional();\n\n expectEqualTypes<false, InferType<typeof falseSchema>>(true);\n expectEqualTypes<false | null, InferType<typeof falseOrNullSchema>>(true);\n expectEqualTypes<false | undefined, InferType<typeof falseOrUndefinedSchema>>(true);\n expectEqualTypes<false | null | undefined, InferType<typeof falseOrNullOrUndefinedSchema>>(true);\n\n const trueSchema = boolean().onlyTrue();\n const trueOrNullSchema = boolean().onlyTrue().nullable();\n const trueOrUndefinedSchema = boolean().onlyTrue().optional();\n const trueOrNullOrUndefinedSchema = boolean().onlyTrue().nullable().optional();\n\n expectEqualTypes<true, InferType<typeof trueSchema>>(true);\n expectEqualTypes<true | null, InferType<typeof trueOrNullSchema>>(true);\n expectEqualTypes<true | undefined, InferType<typeof trueOrUndefinedSchema>>(true);\n expectEqualTypes<true | null | undefined, InferType<typeof trueOrNullOrUndefinedSchema>>(true);\n });\n});\n"],"mappings":";;;AAEO,SAAS,iBAAuB,UAA6B;AAClE,SAAO,OAAO,QAAQ,EAAE,KAAK,SAAS;AACxC;;;ACJO,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;;;AClBO,IAAM,YAAY,OAAO,eAAe;AAKxC,SAAS,WAAW,QAAsB,eAAwB,aAAqB;AAC5F,QAAM,MAAM,OAAO,SAAS;AAC5B,MAAI,kBAAkB,QAAW;AAC/B,QAAI,CAAC,IAAI,WAAY,gBAAe,YAAY,eAAe,aAAa,+BAA+B;AAC3G,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB,MAAM;AAC1B,QAAI,CAAC,IAAI,WAAY,gBAAe,YAAY,eAAe,aAAa,0BAA0B;AACtG,WAAO;AAAA,EACT;AAEA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,UAAU,EAAE,SAAS,EAAE,SAAS;AAE/E,qBAAuD,IAAI;AAC3D,qBAAoE,IAAI;AACxE,qBAA8E,IAAI;AAClF,qBAA2F,IAAI;AAE/F,UAAM,aAAa,QAAQ,EAAE,SAAS;AACtC,UAAM,mBAAmB,QAAQ,EAAE,SAAS,EAAE,SAAS;AACvD,UAAM,wBAAwB,QAAQ,EAAE,SAAS,EAAE,SAAS;AAC5D,UAAM,8BAA8B,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;AAE7E,qBAAqD,IAAI;AACzD,qBAAkE,IAAI;AACtE,qBAA4E,IAAI;AAChF,qBAAyF,IAAI;AAAA,EAC/F,CAAC;AACH,CAAC;","names":["schema"]}
@@ -0,0 +1,217 @@
1
+ // jest/setup.ts
2
+ function expectEqualTypes(areEqual) {
3
+ expect(typeof areEqual).toBe("boolean");
4
+ }
5
+
6
+ // src/exceptions.ts
7
+ var ValidationError = class extends Error {
8
+ expected;
9
+ received;
10
+ pathToError;
11
+ message;
12
+ constructor(expected, received, pathToError, message) {
13
+ super();
14
+ this.expected = expected;
15
+ this.received = received;
16
+ this.pathToError = pathToError;
17
+ this.message = message;
18
+ }
19
+ };
20
+ function throwException(expected, received, pathToError, message) {
21
+ throw new ValidationError(expected, received, pathToError, message);
22
+ }
23
+
24
+ // src/core.ts
25
+ var ctxSymbol = Symbol("contextSymbol");
26
+ function innerCheck(schema, receivedValue, pathToError) {
27
+ const ctx = schema[ctxSymbol];
28
+ if (receivedValue === void 0) {
29
+ if (!ctx.isOptional) throwException("Required", receivedValue, pathToError, "The required value is missing");
30
+ return receivedValue;
31
+ }
32
+ if (receivedValue === null) {
33
+ if (!ctx.isNullable) throwException("Not null", receivedValue, pathToError, "Value should not be null");
34
+ return receivedValue;
35
+ }
36
+ if (ctx.array) {
37
+ if (!Array.isArray(receivedValue))
38
+ throwException("Array", receivedValue, pathToError, "Expected an array but received a different type");
39
+ const schema2 = ctx.array;
40
+ receivedValue.forEach((elem, i) => {
41
+ innerCheck(schema2, elem, `${pathToError}[${i}]`);
42
+ });
43
+ return receivedValue;
44
+ }
45
+ const typeOfVal = typeof receivedValue;
46
+ if (ctx.object) {
47
+ if (typeOfVal !== "object")
48
+ throwException("Object", receivedValue, pathToError, "Expected an object but received a different type");
49
+ if (Array.isArray(receivedValue))
50
+ throwException(
51
+ "Object",
52
+ receivedValue,
53
+ pathToError,
54
+ "Expected an object but received an array. Invalid type of data"
55
+ );
56
+ const shapeSchema = ctx.object;
57
+ for (const keyPerReceivedValue of Object.keys(receivedValue)) {
58
+ if (shapeSchema[keyPerReceivedValue] === void 0)
59
+ throwException("Not allowed", keyPerReceivedValue, pathToError, "This key is not allowed in the object");
60
+ }
61
+ for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {
62
+ const receivedObjectValuePropery = receivedValue[keyOfSchema];
63
+ if (receivedObjectValuePropery === void 0) {
64
+ if (!valueOfSchema[ctxSymbol].isOptional)
65
+ throwException(
66
+ "Required",
67
+ receivedObjectValuePropery,
68
+ pathToError,
69
+ "Missing required property in the object"
70
+ );
71
+ }
72
+ innerCheck(valueOfSchema, receivedObjectValuePropery, `${pathToError}.${keyOfSchema}`);
73
+ }
74
+ return receivedValue;
75
+ }
76
+ if (ctx.type.length) {
77
+ if (!ctx.type.includes(typeOfVal)) throwException(ctx.type, typeOfVal, pathToError, "Invalid type of data");
78
+ }
79
+ ctx.requiredValidations.forEach((requiredValidation) => {
80
+ requiredValidation(receivedValue, pathToError);
81
+ });
82
+ return receivedValue;
83
+ }
84
+
85
+ // src/parseSchema.ts
86
+ function parseSchema(schema, receivedValue) {
87
+ try {
88
+ return innerCheck(schema, receivedValue, "");
89
+ } catch (e) {
90
+ if (e instanceof ValidationError) throw e;
91
+ throw new Error("Something unexpected happened");
92
+ }
93
+ }
94
+
95
+ // src/schemas/CommonSchema.ts
96
+ var CommonSchema = class {
97
+ [ctxSymbol];
98
+ constructor(ctx) {
99
+ this[ctxSymbol] = ctx;
100
+ }
101
+ /**
102
+ * @param validators - One or more custom validation functions.
103
+ * @returns {this} The schema instance with the added custom validation.
104
+ */
105
+ custom(...validators) {
106
+ this[ctxSymbol].requiredValidations.push(...validators);
107
+ return this;
108
+ }
109
+ /**
110
+ * Marks the schema as nullable, allowing the value to be `null`.
111
+ *
112
+ * @returns {WithNull<this>} The schema instance marked as nullable.
113
+ */
114
+ nullable() {
115
+ this[ctxSymbol].isNullable = true;
116
+ return this;
117
+ }
118
+ /**
119
+ * Marks the schema as optional, allowing the value to be `undefined`.
120
+ *
121
+ * @returns {WithUndefined<this>}} The schema instance marked as optional.
122
+ */
123
+ optional() {
124
+ this[ctxSymbol].isOptional = true;
125
+ return this;
126
+ }
127
+ };
128
+
129
+ // src/schemas/BooleanSchema.ts
130
+ var isBoolean = (expected) => (received, pathToError) => {
131
+ if (received !== expected) throwException(expected, received, pathToError, `The received value is not ${expected}`);
132
+ };
133
+ var BooleanSchema = class extends CommonSchema {
134
+ _boolean = 1;
135
+ /**
136
+ * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.
137
+ *
138
+ * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type
139
+ *
140
+ * @example - boolean().onlyTrue(); // Infers the type true
141
+ */
142
+ onlyTrue() {
143
+ return this.custom(isBoolean(true));
144
+ }
145
+ /**
146
+ * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.
147
+ *
148
+ * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type
149
+ *
150
+ * @example - boolean().onlyFalse(); // Infers the type false
151
+ */
152
+ onlyFalse() {
153
+ return this.custom(isBoolean(false));
154
+ }
155
+ };
156
+
157
+ // src/asserts/boolean/index.ts
158
+ function boolean() {
159
+ return new BooleanSchema({ type: ["boolean"], requiredValidations: [] });
160
+ }
161
+
162
+ // src/__tests__/BooleanSchema.test.ts
163
+ describe("BooleanSchema", () => {
164
+ it("should be a boolean", () => {
165
+ const booleanSchema = boolean();
166
+ expectEqualTypes(true);
167
+ expect(parseSchema(booleanSchema, true)).toBe(true);
168
+ expect(parseSchema(booleanSchema, false)).toBe(false);
169
+ });
170
+ it("should not be a boolean", () => {
171
+ const booleanSchema = boolean();
172
+ const actualNotBoolean = 9;
173
+ expectEqualTypes(false);
174
+ expect(() => parseSchema(booleanSchema, actualNotBoolean)).toThrow("Invalid type of data");
175
+ });
176
+ it("should be true", () => {
177
+ const booleanSchema = boolean().onlyTrue();
178
+ expectEqualTypes(true);
179
+ expectEqualTypes(false);
180
+ expect(parseSchema(booleanSchema, true)).toBe(true);
181
+ expect(() => parseSchema(booleanSchema, false)).toThrow("The received value is not true");
182
+ });
183
+ it("should be false", () => {
184
+ const booleanSchema = boolean().onlyFalse();
185
+ expectEqualTypes(true);
186
+ expectEqualTypes(false);
187
+ expect(parseSchema(booleanSchema, false)).toBe(false);
188
+ expect(() => parseSchema(booleanSchema, true)).toThrow("The received value is not false");
189
+ });
190
+ it("should have proper types", () => {
191
+ const booleanSchema = boolean();
192
+ const booleanOrNullSchema = boolean().nullable();
193
+ const booleanOrUndefinedSchema = boolean().optional();
194
+ const booleanOrNullOrUndefinedSchema = boolean().nullable().optional();
195
+ expectEqualTypes(true);
196
+ expectEqualTypes(true);
197
+ expectEqualTypes(true);
198
+ expectEqualTypes(true);
199
+ const falseSchema = boolean().onlyFalse();
200
+ const falseOrNullSchema = boolean().onlyFalse().nullable();
201
+ const falseOrUndefinedSchema = boolean().onlyFalse().optional();
202
+ const falseOrNullOrUndefinedSchema = boolean().onlyFalse().nullable().optional();
203
+ expectEqualTypes(true);
204
+ expectEqualTypes(true);
205
+ expectEqualTypes(true);
206
+ expectEqualTypes(true);
207
+ const trueSchema = boolean().onlyTrue();
208
+ const trueOrNullSchema = boolean().onlyTrue().nullable();
209
+ const trueOrUndefinedSchema = boolean().onlyTrue().optional();
210
+ const trueOrNullOrUndefinedSchema = boolean().onlyTrue().nullable().optional();
211
+ expectEqualTypes(true);
212
+ expectEqualTypes(true);
213
+ expectEqualTypes(true);
214
+ expectEqualTypes(true);
215
+ });
216
+ });
217
+ //# sourceMappingURL=BooleanSchema.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../jest/setup.ts","../../src/exceptions.ts","../../src/core.ts","../../src/parseSchema.ts","../../src/schemas/CommonSchema.ts","../../src/schemas/BooleanSchema.ts","../../src/asserts/boolean/index.ts","../../src/__tests__/BooleanSchema.test.ts"],"sourcesContent":["export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;\n\nexport function expectEqualTypes<X, Y>(areEqual: Equal<X, Y>): void {\n expect(typeof areEqual).toBe('boolean');\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","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 { InferType } from './InferType';\nimport { innerCheck } from './core';\nimport { ValidationError } from './exceptions';\nimport { CommonSchema } from './schemas/CommonSchema';\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe result.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @returns {InferType<T>} The validated value, with its TypeScript type inferred from the schema.\n *\n * @throws {ValidationError} If the received value does not match the schema, a `ValidationError` will be thrown.\n * @throws {Error} If an unexpected error occurs during validation, an error will be thrown with a generic message.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const result = parseSchema(schema, { name: 'Alice', age: 30 });\n * // result will be inferred as { name: string; age: number }\n *\n * parseSchema(schema, { name: 'Alice', age: '30' });\n * // Throws ValidationError because 'age' should be a number, not a string.\n */\nexport function parseSchema<T extends CommonSchema>(schema: T, receivedValue: unknown): InferType<T> {\n try {\n return innerCheck(schema, receivedValue, '') as InferType<T>;\n } catch (e) {\n if (e instanceof ValidationError) throw e;\n /* istanbul ignore next */\n throw new Error('Something unexpected happened');\n }\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 { CommonSchema } from './CommonSchema';\nimport { throwException } from '../exceptions';\n\nconst isBoolean = (expected: boolean) => (received: boolean, pathToError: string) => {\n if (received !== expected) throwException(expected, received, pathToError, `The received value is not ${expected}`);\n};\n\nexport class BooleanSchema extends CommonSchema {\n _boolean = 1;\n\n /**\n * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type\n *\n * @example - boolean().onlyTrue(); // Infers the type true\n */\n onlyTrue(): WithBoolean<this, true> {\n return this.custom(isBoolean(true)) as WithBoolean<this, true>;\n }\n\n /**\n * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type\n *\n * @example - boolean().onlyFalse(); // Infers the type false\n */\n onlyFalse(): WithBoolean<this, false> {\n return this.custom(isBoolean(false)) as WithBoolean<this, false>;\n }\n}\n\nexport type WithBoolean<T extends BooleanSchema, Y = boolean> = T & { validation_boolean: Y };\nexport type ExtractFromBoolean<T> = T extends WithBoolean<BooleanSchema, infer Y> ? Y : never;\n","import { BooleanSchema } from '../../schemas/BooleanSchema';\n\n/**\n * Creates a new schema for validating boolean values.\n *\n * @returns {BooleanSchema} A new instance of `BooleanSchema` for validating booleans.\n *\n * @example\n * const schema = boolean();\n * parseSchema(schema, true); // Validates successfully\n * parseSchema(schema, 'true'); // Throws a validation error\n */\nexport function boolean(): BooleanSchema {\n return new BooleanSchema({ type: ['boolean'], requiredValidations: [] });\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { expectEqualTypes } from '../../jest/setup';\nimport { parseSchema } from '../parseSchema';\nimport { InferType } from '../InferType';\nimport { boolean } from '../asserts/boolean';\n\ndescribe('BooleanSchema', () => {\n it('should be a boolean', () => {\n const booleanSchema = boolean();\n expectEqualTypes<boolean, InferType<typeof booleanSchema>>(true);\n expect(parseSchema(booleanSchema, true)).toBe(true);\n expect(parseSchema(booleanSchema, false)).toBe(false);\n });\n\n it('should not be a boolean', () => {\n const booleanSchema = boolean();\n // eslint-disable-next-line @typescript-eslint/no-inferrable-types\n const actualNotBoolean: number = 9;\n\n expectEqualTypes<typeof actualNotBoolean, InferType<typeof booleanSchema>>(false);\n expect(() => parseSchema(booleanSchema, actualNotBoolean)).toThrow('Invalid type of data');\n });\n\n it('should be true', () => {\n const booleanSchema = boolean().onlyTrue();\n\n expectEqualTypes<true, InferType<typeof booleanSchema>>(true);\n expectEqualTypes<boolean, InferType<typeof booleanSchema>>(false);\n expect(parseSchema(booleanSchema, true)).toBe(true);\n expect(() => parseSchema(booleanSchema, false)).toThrow('The received value is not true');\n });\n\n it('should be false', () => {\n const booleanSchema = boolean().onlyFalse();\n\n expectEqualTypes<false, InferType<typeof booleanSchema>>(true);\n expectEqualTypes<boolean, InferType<typeof booleanSchema>>(false);\n expect(parseSchema(booleanSchema, false)).toBe(false);\n expect(() => parseSchema(booleanSchema, true)).toThrow('The received value is not false');\n });\n\n it('should have proper types', () => {\n const booleanSchema = boolean();\n const booleanOrNullSchema = boolean().nullable();\n const booleanOrUndefinedSchema = boolean().optional();\n const booleanOrNullOrUndefinedSchema = boolean().nullable().optional();\n\n expectEqualTypes<boolean, InferType<typeof booleanSchema>>(true);\n expectEqualTypes<boolean | null, InferType<typeof booleanOrNullSchema>>(true);\n expectEqualTypes<boolean | undefined, InferType<typeof booleanOrUndefinedSchema>>(true);\n expectEqualTypes<boolean | null | undefined, InferType<typeof booleanOrNullOrUndefinedSchema>>(true);\n\n const falseSchema = boolean().onlyFalse();\n const falseOrNullSchema = boolean().onlyFalse().nullable();\n const falseOrUndefinedSchema = boolean().onlyFalse().optional();\n const falseOrNullOrUndefinedSchema = boolean().onlyFalse().nullable().optional();\n\n expectEqualTypes<false, InferType<typeof falseSchema>>(true);\n expectEqualTypes<false | null, InferType<typeof falseOrNullSchema>>(true);\n expectEqualTypes<false | undefined, InferType<typeof falseOrUndefinedSchema>>(true);\n expectEqualTypes<false | null | undefined, InferType<typeof falseOrNullOrUndefinedSchema>>(true);\n\n const trueSchema = boolean().onlyTrue();\n const trueOrNullSchema = boolean().onlyTrue().nullable();\n const trueOrUndefinedSchema = boolean().onlyTrue().optional();\n const trueOrNullOrUndefinedSchema = boolean().onlyTrue().nullable().optional();\n\n expectEqualTypes<true, InferType<typeof trueSchema>>(true);\n expectEqualTypes<true | null, InferType<typeof trueOrNullSchema>>(true);\n expectEqualTypes<true | undefined, InferType<typeof trueOrUndefinedSchema>>(true);\n expectEqualTypes<true | null | undefined, InferType<typeof trueOrNullOrUndefinedSchema>>(true);\n });\n});\n"],"mappings":";AAEO,SAAS,iBAAuB,UAA6B;AAClE,SAAO,OAAO,QAAQ,EAAE,KAAK,SAAS;AACxC;;;ACJO,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;;;AClBO,IAAM,YAAY,OAAO,eAAe;AAKxC,SAAS,WAAW,QAAsB,eAAwB,aAAqB;AAC5F,QAAM,MAAM,OAAO,SAAS;AAC5B,MAAI,kBAAkB,QAAW;AAC/B,QAAI,CAAC,IAAI,WAAY,gBAAe,YAAY,eAAe,aAAa,+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