bguard 0.0.2 → 0.0.4
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.
- package/lib/CommonSchema-DeTBsQhn.d.mts +57 -0
- package/lib/CommonSchema-DeTBsQhn.d.ts +57 -0
- package/lib/asserts/array/index.d.mts +2 -0
- package/lib/asserts/array/index.d.ts +2 -0
- package/lib/asserts/array/index.js +90 -0
- package/lib/asserts/array/index.js.map +1 -0
- package/lib/asserts/array/index.mjs +63 -0
- package/lib/asserts/array/index.mjs.map +1 -0
- package/lib/asserts/boolean/index.d.mts +2 -0
- package/lib/asserts/boolean/index.d.ts +2 -0
- package/lib/asserts/boolean/index.js +118 -0
- package/lib/asserts/boolean/index.js.map +1 -0
- package/lib/asserts/boolean/index.mjs +91 -0
- package/lib/asserts/boolean/index.mjs.map +1 -0
- package/lib/asserts/common/equalTo.d.mts +29 -0
- package/lib/asserts/common/equalTo.d.ts +29 -0
- package/lib/asserts/common/equalTo.js +54 -0
- package/lib/asserts/common/equalTo.js.map +1 -0
- package/lib/asserts/common/equalTo.mjs +27 -0
- package/lib/asserts/common/equalTo.mjs.map +1 -0
- package/lib/asserts/common/index.d.mts +18 -0
- package/lib/asserts/common/index.d.ts +18 -0
- package/lib/asserts/common/index.js +72 -0
- package/lib/asserts/common/index.js.map +1 -0
- package/lib/asserts/common/index.mjs +45 -0
- package/lib/asserts/common/index.mjs.map +1 -0
- package/lib/asserts/number/index.d.mts +2 -0
- package/lib/asserts/number/index.d.ts +2 -0
- package/lib/asserts/number/index.js +112 -0
- package/lib/asserts/number/index.js.map +1 -0
- package/lib/asserts/number/index.mjs +85 -0
- package/lib/asserts/number/index.mjs.map +1 -0
- package/lib/asserts/number/max.d.mts +17 -0
- package/lib/asserts/number/max.d.ts +17 -0
- package/lib/asserts/number/max.js +54 -0
- package/lib/asserts/number/max.js.map +1 -0
- package/lib/asserts/number/max.mjs +27 -0
- package/lib/asserts/number/max.mjs.map +1 -0
- package/lib/asserts/number/maxExcluded.d.mts +17 -0
- package/lib/asserts/number/maxExcluded.d.ts +17 -0
- package/lib/asserts/number/maxExcluded.js +54 -0
- package/lib/asserts/number/maxExcluded.js.map +1 -0
- package/lib/asserts/number/maxExcluded.mjs +27 -0
- package/lib/asserts/number/maxExcluded.mjs.map +1 -0
- package/lib/asserts/number/min.d.mts +17 -0
- package/lib/asserts/number/min.d.ts +17 -0
- package/lib/asserts/number/min.js +54 -0
- package/lib/asserts/number/min.js.map +1 -0
- package/lib/asserts/number/min.mjs +27 -0
- package/lib/asserts/number/min.mjs.map +1 -0
- package/lib/asserts/number/minExcluded.d.mts +17 -0
- package/lib/asserts/number/minExcluded.d.ts +17 -0
- package/lib/asserts/number/minExcluded.js +54 -0
- package/lib/asserts/number/minExcluded.js.map +1 -0
- package/lib/asserts/number/minExcluded.mjs +27 -0
- package/lib/asserts/number/minExcluded.mjs.map +1 -0
- package/lib/asserts/number/negative.d.mts +16 -0
- package/lib/asserts/number/negative.d.ts +16 -0
- package/lib/asserts/number/negative.js +53 -0
- package/lib/asserts/number/negative.js.map +1 -0
- package/lib/asserts/number/negative.mjs +26 -0
- package/lib/asserts/number/negative.mjs.map +1 -0
- package/lib/asserts/number/positive.d.mts +16 -0
- package/lib/asserts/number/positive.d.ts +16 -0
- package/lib/asserts/number/positive.js +53 -0
- package/lib/asserts/number/positive.js.map +1 -0
- package/lib/asserts/number/positive.mjs +26 -0
- package/lib/asserts/number/positive.mjs.map +1 -0
- package/lib/asserts/object/index.d.mts +2 -0
- package/lib/asserts/object/index.d.ts +2 -0
- package/lib/asserts/object/index.js +94 -0
- package/lib/asserts/object/index.js.map +1 -0
- package/lib/asserts/object/index.mjs +67 -0
- package/lib/asserts/object/index.mjs.map +1 -0
- package/lib/asserts/string/email.d.mts +16 -0
- package/lib/asserts/string/email.d.ts +16 -0
- package/lib/asserts/string/email.js +55 -0
- package/lib/asserts/string/email.js.map +1 -0
- package/lib/asserts/string/email.mjs +28 -0
- package/lib/asserts/string/email.mjs.map +1 -0
- package/lib/asserts/string/index.d.mts +2 -0
- package/lib/asserts/string/index.d.ts +2 -0
- package/lib/asserts/string/index.js +112 -0
- package/lib/asserts/string/index.js.map +1 -0
- package/lib/asserts/string/index.mjs +85 -0
- package/lib/asserts/string/index.mjs.map +1 -0
- package/lib/asserts/string/maxLength.d.mts +16 -0
- package/lib/asserts/string/maxLength.d.ts +16 -0
- package/lib/asserts/string/maxLength.js +54 -0
- package/lib/asserts/string/maxLength.js.map +1 -0
- package/lib/asserts/string/maxLength.mjs +27 -0
- package/lib/asserts/string/maxLength.mjs.map +1 -0
- package/lib/asserts/string/minLength.d.mts +16 -0
- package/lib/asserts/string/minLength.d.ts +16 -0
- package/lib/asserts/string/minLength.js +54 -0
- package/lib/asserts/string/minLength.js.map +1 -0
- package/lib/asserts/string/minLength.mjs +27 -0
- package/lib/asserts/string/minLength.mjs.map +1 -0
- package/lib/asserts/string/regExp.d.mts +16 -0
- package/lib/asserts/string/regExp.d.ts +16 -0
- package/lib/asserts/string/regExp.js +54 -0
- package/lib/asserts/string/regExp.js.map +1 -0
- package/lib/asserts/string/regExp.mjs +27 -0
- package/lib/asserts/string/regExp.mjs.map +1 -0
- package/lib/index-B1yBez0g.d.ts +39 -0
- package/lib/index-B63cXDOm.d.mts +32 -0
- package/lib/index-BEyBEBSm.d.ts +32 -0
- package/lib/index-CK_g_aEC.d.ts +32 -0
- package/lib/index-D3R2euaT.d.mts +29 -0
- package/lib/index-DPkImfCy.d.ts +29 -0
- package/lib/index-DitgsWDO.d.ts +27 -0
- package/lib/index-T3KBmyyn.d.mts +27 -0
- package/lib/index-aBEYpJdZ.d.mts +32 -0
- package/lib/index-nzqBrOHf.d.mts +39 -0
- package/lib/index.d.mts +52 -0
- package/lib/index.d.ts +52 -0
- package/lib/index.js +295 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +262 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +39 -3
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/exceptions.ts
|
|
2
|
+
var ValidationError = class extends Error {
|
|
3
|
+
expected;
|
|
4
|
+
received;
|
|
5
|
+
pathToError;
|
|
6
|
+
message;
|
|
7
|
+
constructor(expected, received, pathToError, message) {
|
|
8
|
+
super();
|
|
9
|
+
this.expected = expected;
|
|
10
|
+
this.received = received;
|
|
11
|
+
this.pathToError = pathToError;
|
|
12
|
+
this.message = message;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function throwException(expected, received, pathToError, message) {
|
|
16
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/asserts/number/max.ts
|
|
20
|
+
var max = (expected) => (received, pathToError) => {
|
|
21
|
+
if (expected < received)
|
|
22
|
+
throwException(expected, received, pathToError, "The received value is greater than expected");
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
max
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=max.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/number/max.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value does not exceed a specified maximum value.\n *\n * @param {number} expected - The maximum allowable value.\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value exceeds the expected maximum value.\n *\n * @example\n * const schema = number().custom(max(100));\n * parseSchema(schema, 99); // Valid\n * parseSchema(schema, 100); // Valid\n * parseSchema(schema, 101); // Throws an error: 'The received value is greater than expected'\n */\nexport const max =\n (expected: number): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected < received)\n throwException(expected, received, pathToError, 'The received value is greater than expected');\n };\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACHO,IAAM,MACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,WAAW;AACb,mBAAe,UAAU,UAAU,aAAa,6CAA6C;AACjG;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is strictly less than a specified maximum value (i.e., the maximum value is excluded).
|
|
5
|
+
*
|
|
6
|
+
* @param {number} expected - The maximum allowable value, which is excluded.
|
|
7
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is greater than or equal to the expected maximum value.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const schema = number().custom(maxExcluded(100));
|
|
11
|
+
* parseSchema(schema, 99); // Valid
|
|
12
|
+
* parseSchema(schema, 100); // Throws an error: 'The received value is greater than or equal to expected'
|
|
13
|
+
* parseSchema(schema, 101); // Throws an error: 'The received value is greater than or equal to expected'
|
|
14
|
+
*/
|
|
15
|
+
declare const maxExcluded: (expected: number) => RequiredValidation;
|
|
16
|
+
|
|
17
|
+
export { maxExcluded };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is strictly less than a specified maximum value (i.e., the maximum value is excluded).
|
|
5
|
+
*
|
|
6
|
+
* @param {number} expected - The maximum allowable value, which is excluded.
|
|
7
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is greater than or equal to the expected maximum value.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const schema = number().custom(maxExcluded(100));
|
|
11
|
+
* parseSchema(schema, 99); // Valid
|
|
12
|
+
* parseSchema(schema, 100); // Throws an error: 'The received value is greater than or equal to expected'
|
|
13
|
+
* parseSchema(schema, 101); // Throws an error: 'The received value is greater than or equal to expected'
|
|
14
|
+
*/
|
|
15
|
+
declare const maxExcluded: (expected: number) => RequiredValidation;
|
|
16
|
+
|
|
17
|
+
export { maxExcluded };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/asserts/number/maxExcluded.ts
|
|
21
|
+
var maxExcluded_exports = {};
|
|
22
|
+
__export(maxExcluded_exports, {
|
|
23
|
+
maxExcluded: () => maxExcluded
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(maxExcluded_exports);
|
|
26
|
+
|
|
27
|
+
// src/exceptions.ts
|
|
28
|
+
var ValidationError = class extends Error {
|
|
29
|
+
expected;
|
|
30
|
+
received;
|
|
31
|
+
pathToError;
|
|
32
|
+
message;
|
|
33
|
+
constructor(expected, received, pathToError, message) {
|
|
34
|
+
super();
|
|
35
|
+
this.expected = expected;
|
|
36
|
+
this.received = received;
|
|
37
|
+
this.pathToError = pathToError;
|
|
38
|
+
this.message = message;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function throwException(expected, received, pathToError, message) {
|
|
42
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/asserts/number/maxExcluded.ts
|
|
46
|
+
var maxExcluded = (expected) => (received, pathToError) => {
|
|
47
|
+
if (expected <= received)
|
|
48
|
+
throwException(expected, received, pathToError, "The received value is greater than or equal to expected");
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
maxExcluded
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=maxExcluded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/number/maxExcluded.ts","../../../src/exceptions.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value is strictly less than a specified maximum value (i.e., the maximum value is excluded).\n *\n * @param {number} expected - The maximum allowable value, which is excluded.\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is greater than or equal to the expected maximum value.\n *\n * @example\n * const schema = number().custom(maxExcluded(100));\n * parseSchema(schema, 99); // Valid\n * parseSchema(schema, 100); // Throws an error: 'The received value is greater than or equal to expected'\n * parseSchema(schema, 101); // Throws an error: 'The received value is greater than or equal to expected'\n */\nexport const maxExcluded =\n (expected: number): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected <= received)\n throwException(expected, received, pathToError, 'The received value is greater than or equal to expected');\n };\n","export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ADHO,IAAM,cACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,YAAY;AACd,mBAAe,UAAU,UAAU,aAAa,yDAAyD;AAC7G;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/exceptions.ts
|
|
2
|
+
var ValidationError = class extends Error {
|
|
3
|
+
expected;
|
|
4
|
+
received;
|
|
5
|
+
pathToError;
|
|
6
|
+
message;
|
|
7
|
+
constructor(expected, received, pathToError, message) {
|
|
8
|
+
super();
|
|
9
|
+
this.expected = expected;
|
|
10
|
+
this.received = received;
|
|
11
|
+
this.pathToError = pathToError;
|
|
12
|
+
this.message = message;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function throwException(expected, received, pathToError, message) {
|
|
16
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/asserts/number/maxExcluded.ts
|
|
20
|
+
var maxExcluded = (expected) => (received, pathToError) => {
|
|
21
|
+
if (expected <= received)
|
|
22
|
+
throwException(expected, received, pathToError, "The received value is greater than or equal to expected");
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
maxExcluded
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=maxExcluded.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/number/maxExcluded.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value is strictly less than a specified maximum value (i.e., the maximum value is excluded).\n *\n * @param {number} expected - The maximum allowable value, which is excluded.\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is greater than or equal to the expected maximum value.\n *\n * @example\n * const schema = number().custom(maxExcluded(100));\n * parseSchema(schema, 99); // Valid\n * parseSchema(schema, 100); // Throws an error: 'The received value is greater than or equal to expected'\n * parseSchema(schema, 101); // Throws an error: 'The received value is greater than or equal to expected'\n */\nexport const maxExcluded =\n (expected: number): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected <= received)\n throwException(expected, received, pathToError, 'The received value is greater than or equal to expected');\n };\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACHO,IAAM,cACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,YAAY;AACd,mBAAe,UAAU,UAAU,aAAa,yDAAyD;AAC7G;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is not less than a specified minimum value.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} expected - The minimum allowable value.
|
|
7
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is less than the expected minimum value.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const schema = number().custom(min(10));
|
|
11
|
+
* parseSchema(schema, 11); // Valid
|
|
12
|
+
* parseSchema(schema, 10); // Valid
|
|
13
|
+
* parseSchema(schema, 9); // Throws an error: 'The received value is less than expected'
|
|
14
|
+
*/
|
|
15
|
+
declare const min: (expected: number) => RequiredValidation;
|
|
16
|
+
|
|
17
|
+
export { min };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is not less than a specified minimum value.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} expected - The minimum allowable value.
|
|
7
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is less than the expected minimum value.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const schema = number().custom(min(10));
|
|
11
|
+
* parseSchema(schema, 11); // Valid
|
|
12
|
+
* parseSchema(schema, 10); // Valid
|
|
13
|
+
* parseSchema(schema, 9); // Throws an error: 'The received value is less than expected'
|
|
14
|
+
*/
|
|
15
|
+
declare const min: (expected: number) => RequiredValidation;
|
|
16
|
+
|
|
17
|
+
export { min };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/asserts/number/min.ts
|
|
21
|
+
var min_exports = {};
|
|
22
|
+
__export(min_exports, {
|
|
23
|
+
min: () => min
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(min_exports);
|
|
26
|
+
|
|
27
|
+
// src/exceptions.ts
|
|
28
|
+
var ValidationError = class extends Error {
|
|
29
|
+
expected;
|
|
30
|
+
received;
|
|
31
|
+
pathToError;
|
|
32
|
+
message;
|
|
33
|
+
constructor(expected, received, pathToError, message) {
|
|
34
|
+
super();
|
|
35
|
+
this.expected = expected;
|
|
36
|
+
this.received = received;
|
|
37
|
+
this.pathToError = pathToError;
|
|
38
|
+
this.message = message;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function throwException(expected, received, pathToError, message) {
|
|
42
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/asserts/number/min.ts
|
|
46
|
+
var min = (expected) => (received, pathToError) => {
|
|
47
|
+
if (expected > received)
|
|
48
|
+
throwException(expected, received, pathToError, "The received value is less than expected");
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
min
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/number/min.ts","../../../src/exceptions.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value is not less than a specified minimum value.\n *\n * @param {number} expected - The minimum allowable value.\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is less than the expected minimum value.\n *\n * @example\n * const schema = number().custom(min(10));\n * parseSchema(schema, 11); // Valid\n * parseSchema(schema, 10); // Valid\n * parseSchema(schema, 9); // Throws an error: 'The received value is less than expected'\n */\nexport const min =\n (expected: number): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected > received)\n throwException(expected, received, pathToError, 'The received value is less than expected');\n };\n","export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ADHO,IAAM,MACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,WAAW;AACb,mBAAe,UAAU,UAAU,aAAa,0CAA0C;AAC9F;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/exceptions.ts
|
|
2
|
+
var ValidationError = class extends Error {
|
|
3
|
+
expected;
|
|
4
|
+
received;
|
|
5
|
+
pathToError;
|
|
6
|
+
message;
|
|
7
|
+
constructor(expected, received, pathToError, message) {
|
|
8
|
+
super();
|
|
9
|
+
this.expected = expected;
|
|
10
|
+
this.received = received;
|
|
11
|
+
this.pathToError = pathToError;
|
|
12
|
+
this.message = message;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function throwException(expected, received, pathToError, message) {
|
|
16
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/asserts/number/min.ts
|
|
20
|
+
var min = (expected) => (received, pathToError) => {
|
|
21
|
+
if (expected > received)
|
|
22
|
+
throwException(expected, received, pathToError, "The received value is less than expected");
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
min
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=min.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/number/min.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value is not less than a specified minimum value.\n *\n * @param {number} expected - The minimum allowable value.\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is less than the expected minimum value.\n *\n * @example\n * const schema = number().custom(min(10));\n * parseSchema(schema, 11); // Valid\n * parseSchema(schema, 10); // Valid\n * parseSchema(schema, 9); // Throws an error: 'The received value is less than expected'\n */\nexport const min =\n (expected: number): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected > received)\n throwException(expected, received, pathToError, 'The received value is less than expected');\n };\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACHO,IAAM,MACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,WAAW;AACb,mBAAe,UAAU,UAAU,aAAa,0CAA0C;AAC9F;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).
|
|
5
|
+
*
|
|
6
|
+
* @param {number} expected - The minimum allowable value, which is excluded.
|
|
7
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is less than or equal to the expected minimum value.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const schema = number().custom(minExcluded(10));
|
|
11
|
+
* parseSchema(schema, 11); // Valid
|
|
12
|
+
* parseSchema(schema, 10); // Throws an error: 'The received value is less than or equal to expected'
|
|
13
|
+
* parseSchema(schema, 9); // Throws an error: 'The received value is less than or equal to expected'
|
|
14
|
+
*/
|
|
15
|
+
declare const minExcluded: (expected: number) => RequiredValidation;
|
|
16
|
+
|
|
17
|
+
export { minExcluded };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).
|
|
5
|
+
*
|
|
6
|
+
* @param {number} expected - The minimum allowable value, which is excluded.
|
|
7
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is less than or equal to the expected minimum value.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const schema = number().custom(minExcluded(10));
|
|
11
|
+
* parseSchema(schema, 11); // Valid
|
|
12
|
+
* parseSchema(schema, 10); // Throws an error: 'The received value is less than or equal to expected'
|
|
13
|
+
* parseSchema(schema, 9); // Throws an error: 'The received value is less than or equal to expected'
|
|
14
|
+
*/
|
|
15
|
+
declare const minExcluded: (expected: number) => RequiredValidation;
|
|
16
|
+
|
|
17
|
+
export { minExcluded };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/asserts/number/minExcluded.ts
|
|
21
|
+
var minExcluded_exports = {};
|
|
22
|
+
__export(minExcluded_exports, {
|
|
23
|
+
minExcluded: () => minExcluded
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(minExcluded_exports);
|
|
26
|
+
|
|
27
|
+
// src/exceptions.ts
|
|
28
|
+
var ValidationError = class extends Error {
|
|
29
|
+
expected;
|
|
30
|
+
received;
|
|
31
|
+
pathToError;
|
|
32
|
+
message;
|
|
33
|
+
constructor(expected, received, pathToError, message) {
|
|
34
|
+
super();
|
|
35
|
+
this.expected = expected;
|
|
36
|
+
this.received = received;
|
|
37
|
+
this.pathToError = pathToError;
|
|
38
|
+
this.message = message;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function throwException(expected, received, pathToError, message) {
|
|
42
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/asserts/number/minExcluded.ts
|
|
46
|
+
var minExcluded = (expected) => (received, pathToError) => {
|
|
47
|
+
if (expected >= received)
|
|
48
|
+
throwException(expected, received, pathToError, "The received value is less than or equal to expected");
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
minExcluded
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=minExcluded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/number/minExcluded.ts","../../../src/exceptions.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).\n *\n * @param {number} expected - The minimum allowable value, which is excluded.\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is less than or equal to the expected minimum value.\n *\n * @example\n * const schema = number().custom(minExcluded(10));\n * parseSchema(schema, 11); // Valid\n * parseSchema(schema, 10); // Throws an error: 'The received value is less than or equal to expected'\n * parseSchema(schema, 9); // Throws an error: 'The received value is less than or equal to expected'\n */\nexport const minExcluded =\n (expected: number): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected >= received)\n throwException(expected, received, pathToError, 'The received value is less than or equal to expected');\n };\n","export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ADHO,IAAM,cACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,YAAY;AACd,mBAAe,UAAU,UAAU,aAAa,sDAAsD;AAC1G;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/exceptions.ts
|
|
2
|
+
var ValidationError = class extends Error {
|
|
3
|
+
expected;
|
|
4
|
+
received;
|
|
5
|
+
pathToError;
|
|
6
|
+
message;
|
|
7
|
+
constructor(expected, received, pathToError, message) {
|
|
8
|
+
super();
|
|
9
|
+
this.expected = expected;
|
|
10
|
+
this.received = received;
|
|
11
|
+
this.pathToError = pathToError;
|
|
12
|
+
this.message = message;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function throwException(expected, received, pathToError, message) {
|
|
16
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/asserts/number/minExcluded.ts
|
|
20
|
+
var minExcluded = (expected) => (received, pathToError) => {
|
|
21
|
+
if (expected >= received)
|
|
22
|
+
throwException(expected, received, pathToError, "The received value is less than or equal to expected");
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
minExcluded
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=minExcluded.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/number/minExcluded.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).\n *\n * @param {number} expected - The minimum allowable value, which is excluded.\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is less than or equal to the expected minimum value.\n *\n * @example\n * const schema = number().custom(minExcluded(10));\n * parseSchema(schema, 11); // Valid\n * parseSchema(schema, 10); // Throws an error: 'The received value is less than or equal to expected'\n * parseSchema(schema, 9); // Throws an error: 'The received value is less than or equal to expected'\n */\nexport const minExcluded =\n (expected: number): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected >= received)\n throwException(expected, received, pathToError, 'The received value is less than or equal to expected');\n };\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACHO,IAAM,cACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,YAAY;AACd,mBAAe,UAAU,UAAU,aAAa,sDAAsD;AAC1G;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is negative (less than zero).
|
|
5
|
+
*
|
|
6
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is not negative.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = number().custom(negative());
|
|
10
|
+
* parseSchema(schema, -10); // Valid
|
|
11
|
+
* parseSchema(schema, 0); // Throws an error: 'The received value is not a negative number'
|
|
12
|
+
* parseSchema(schema, 5); // Throws an error: 'The received value is not a negative number'
|
|
13
|
+
*/
|
|
14
|
+
declare const negative: () => RequiredValidation;
|
|
15
|
+
|
|
16
|
+
export { negative };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is negative (less than zero).
|
|
5
|
+
*
|
|
6
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is not negative.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = number().custom(negative());
|
|
10
|
+
* parseSchema(schema, -10); // Valid
|
|
11
|
+
* parseSchema(schema, 0); // Throws an error: 'The received value is not a negative number'
|
|
12
|
+
* parseSchema(schema, 5); // Throws an error: 'The received value is not a negative number'
|
|
13
|
+
*/
|
|
14
|
+
declare const negative: () => RequiredValidation;
|
|
15
|
+
|
|
16
|
+
export { negative };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/asserts/number/negative.ts
|
|
21
|
+
var negative_exports = {};
|
|
22
|
+
__export(negative_exports, {
|
|
23
|
+
negative: () => negative
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(negative_exports);
|
|
26
|
+
|
|
27
|
+
// src/exceptions.ts
|
|
28
|
+
var ValidationError = class extends Error {
|
|
29
|
+
expected;
|
|
30
|
+
received;
|
|
31
|
+
pathToError;
|
|
32
|
+
message;
|
|
33
|
+
constructor(expected, received, pathToError, message) {
|
|
34
|
+
super();
|
|
35
|
+
this.expected = expected;
|
|
36
|
+
this.received = received;
|
|
37
|
+
this.pathToError = pathToError;
|
|
38
|
+
this.message = message;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function throwException(expected, received, pathToError, message) {
|
|
42
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/asserts/number/negative.ts
|
|
46
|
+
var negative = () => (received, pathToError) => {
|
|
47
|
+
if (received >= 0) throwException("negative", received, pathToError, "The received value is not a negative number");
|
|
48
|
+
};
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
negative
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=negative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/number/negative.ts","../../../src/exceptions.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value is negative (less than zero).\n *\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is not negative.\n *\n * @example\n * const schema = number().custom(negative());\n * parseSchema(schema, -10); // Valid\n * parseSchema(schema, 0); // Throws an error: 'The received value is not a negative number'\n * parseSchema(schema, 5); // Throws an error: 'The received value is not a negative number'\n */\nexport const negative = (): RequiredValidation => (received: number, pathToError: string) => {\n if (received >= 0) throwException('negative', received, pathToError, 'The received value is not a negative number');\n};\n","export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ADJO,IAAM,WAAW,MAA0B,CAAC,UAAkB,gBAAwB;AAC3F,MAAI,YAAY,EAAG,gBAAe,YAAY,UAAU,aAAa,6CAA6C;AACpH;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/exceptions.ts
|
|
2
|
+
var ValidationError = class extends Error {
|
|
3
|
+
expected;
|
|
4
|
+
received;
|
|
5
|
+
pathToError;
|
|
6
|
+
message;
|
|
7
|
+
constructor(expected, received, pathToError, message) {
|
|
8
|
+
super();
|
|
9
|
+
this.expected = expected;
|
|
10
|
+
this.received = received;
|
|
11
|
+
this.pathToError = pathToError;
|
|
12
|
+
this.message = message;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function throwException(expected, received, pathToError, message) {
|
|
16
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/asserts/number/negative.ts
|
|
20
|
+
var negative = () => (received, pathToError) => {
|
|
21
|
+
if (received >= 0) throwException("negative", received, pathToError, "The received value is not a negative number");
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
negative
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=negative.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions.ts","../../../src/asserts/number/negative.ts"],"sourcesContent":["export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n","import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a number value is negative (less than zero).\n *\n * @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is not negative.\n *\n * @example\n * const schema = number().custom(negative());\n * parseSchema(schema, -10); // Valid\n * parseSchema(schema, 0); // Throws an error: 'The received value is not a negative number'\n * parseSchema(schema, 5); // Throws an error: 'The received value is not a negative number'\n */\nexport const negative = (): RequiredValidation => (received: number, pathToError: string) => {\n if (received >= 0) throwException('negative', received, pathToError, 'The received value is not a negative number');\n};\n"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAIO,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;;;ACJO,IAAM,WAAW,MAA0B,CAAC,UAAkB,gBAAwB;AAC3F,MAAI,YAAY,EAAG,gBAAe,YAAY,UAAU,aAAa,6CAA6C;AACpH;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is positive (greater than zero).
|
|
5
|
+
*
|
|
6
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is not positive.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = number().custom(positive());
|
|
10
|
+
* parseSchema(schema, 10); // Valid
|
|
11
|
+
* parseSchema(schema, 0); // Throws an error: 'The received value is not a positive number'
|
|
12
|
+
* parseSchema(schema, -5); // Throws an error: 'The received value is not a positive number'
|
|
13
|
+
*/
|
|
14
|
+
declare const positive: () => RequiredValidation;
|
|
15
|
+
|
|
16
|
+
export { positive };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { R as RequiredValidation } from '../../CommonSchema-DeTBsQhn.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that a number value is positive (greater than zero).
|
|
5
|
+
*
|
|
6
|
+
* @returns {RequiredValidation} - A validation function that takes a received number and a path to the error message. Throws an error if the received value is not positive.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = number().custom(positive());
|
|
10
|
+
* parseSchema(schema, 10); // Valid
|
|
11
|
+
* parseSchema(schema, 0); // Throws an error: 'The received value is not a positive number'
|
|
12
|
+
* parseSchema(schema, -5); // Throws an error: 'The received value is not a positive number'
|
|
13
|
+
*/
|
|
14
|
+
declare const positive: () => RequiredValidation;
|
|
15
|
+
|
|
16
|
+
export { positive };
|