bguard 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +359 -25
- package/lib/asserts/number/index.js +4 -3
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +3 -2
- package/lib/asserts/string/atLeastOneDigit.d.mts +20 -0
- package/lib/asserts/string/atLeastOneDigit.d.ts +20 -0
- package/lib/asserts/string/atLeastOneDigit.js +21 -0
- package/lib/asserts/string/atLeastOneDigit.js.map +1 -0
- package/lib/asserts/string/atLeastOneDigit.mjs +21 -0
- package/lib/asserts/string/atLeastOneDigit.mjs.map +1 -0
- package/lib/asserts/string/atLeastOneLowerChar.d.mts +20 -0
- package/lib/asserts/string/atLeastOneLowerChar.d.ts +20 -0
- package/lib/asserts/string/atLeastOneLowerChar.js +22 -0
- package/lib/asserts/string/atLeastOneLowerChar.js.map +1 -0
- package/lib/asserts/string/atLeastOneLowerChar.mjs +22 -0
- package/lib/asserts/string/atLeastOneLowerChar.mjs.map +1 -0
- package/lib/asserts/string/atLeastOneSpecialChar.d.mts +25 -0
- package/lib/asserts/string/atLeastOneSpecialChar.d.ts +25 -0
- package/lib/asserts/string/atLeastOneSpecialChar.js +26 -0
- package/lib/asserts/string/atLeastOneSpecialChar.js.map +1 -0
- package/lib/asserts/string/atLeastOneSpecialChar.mjs +26 -0
- package/lib/asserts/string/atLeastOneSpecialChar.mjs.map +1 -0
- package/lib/asserts/string/atLeastOneUpperChar.d.mts +20 -0
- package/lib/asserts/string/atLeastOneUpperChar.d.ts +20 -0
- package/lib/asserts/string/atLeastOneUpperChar.js +22 -0
- package/lib/asserts/string/atLeastOneUpperChar.js.map +1 -0
- package/lib/asserts/string/atLeastOneUpperChar.mjs +22 -0
- package/lib/asserts/string/atLeastOneUpperChar.mjs.map +1 -0
- package/lib/asserts/string/contains.d.mts +21 -0
- package/lib/asserts/string/contains.d.ts +21 -0
- package/lib/asserts/string/contains.js +22 -0
- package/lib/asserts/string/contains.js.map +1 -0
- package/lib/asserts/string/contains.mjs +22 -0
- package/lib/asserts/string/contains.mjs.map +1 -0
- package/lib/asserts/string/endsWith.d.mts +21 -0
- package/lib/asserts/string/endsWith.d.ts +21 -0
- package/lib/asserts/string/endsWith.js +22 -0
- package/lib/asserts/string/endsWith.js.map +1 -0
- package/lib/asserts/string/endsWith.mjs +22 -0
- package/lib/asserts/string/endsWith.mjs.map +1 -0
- package/lib/asserts/string/index.js +4 -3
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +3 -2
- package/lib/asserts/string/lowerCase.d.mts +20 -0
- package/lib/asserts/string/lowerCase.d.ts +20 -0
- package/lib/asserts/string/lowerCase.js +20 -0
- package/lib/asserts/string/lowerCase.js.map +1 -0
- package/lib/asserts/string/lowerCase.mjs +20 -0
- package/lib/asserts/string/lowerCase.mjs.map +1 -0
- package/lib/asserts/string/maxLength.d.mts +1 -1
- package/lib/asserts/string/maxLength.d.ts +1 -1
- package/lib/asserts/string/maxLength.js.map +1 -1
- package/lib/asserts/string/maxLength.mjs.map +1 -1
- package/lib/asserts/string/minLength.d.mts +1 -1
- package/lib/asserts/string/minLength.d.ts +1 -1
- package/lib/asserts/string/minLength.js.map +1 -1
- package/lib/asserts/string/minLength.mjs.map +1 -1
- package/lib/asserts/string/regExp.d.mts +1 -1
- package/lib/asserts/string/regExp.d.ts +1 -1
- package/lib/asserts/string/regExp.js.map +1 -1
- package/lib/asserts/string/regExp.mjs.map +1 -1
- package/lib/asserts/string/startsWith.d.mts +21 -0
- package/lib/asserts/string/startsWith.d.ts +21 -0
- package/lib/asserts/string/startsWith.js +22 -0
- package/lib/asserts/string/startsWith.js.map +1 -0
- package/lib/asserts/string/startsWith.mjs +22 -0
- package/lib/asserts/string/startsWith.mjs.map +1 -0
- package/lib/asserts/string/upperCase.d.mts +21 -0
- package/lib/asserts/string/upperCase.d.ts +21 -0
- package/lib/asserts/string/upperCase.js +22 -0
- package/lib/asserts/string/upperCase.js.map +1 -0
- package/lib/asserts/string/upperCase.mjs +22 -0
- package/lib/asserts/string/upperCase.mjs.map +1 -0
- package/lib/asserts/string/uuid.d.mts +20 -0
- package/lib/asserts/string/uuid.d.ts +20 -0
- package/lib/asserts/string/uuid.js +23 -0
- package/lib/asserts/string/uuid.js.map +1 -0
- package/lib/asserts/string/uuid.mjs +23 -0
- package/lib/asserts/string/uuid.mjs.map +1 -0
- package/lib/asserts/string/uuidV1.d.mts +21 -0
- package/lib/asserts/string/uuidV1.d.ts +21 -0
- package/lib/asserts/string/uuidV1.js +23 -0
- package/lib/asserts/string/uuidV1.js.map +1 -0
- package/lib/asserts/string/uuidV1.mjs +23 -0
- package/lib/asserts/string/uuidV1.mjs.map +1 -0
- package/lib/asserts/string/uuidV2.d.mts +21 -0
- package/lib/asserts/string/uuidV2.d.ts +21 -0
- package/lib/asserts/string/uuidV2.js +23 -0
- package/lib/asserts/string/uuidV2.js.map +1 -0
- package/lib/asserts/string/uuidV2.mjs +23 -0
- package/lib/asserts/string/uuidV2.mjs.map +1 -0
- package/lib/asserts/string/uuidV3.d.mts +21 -0
- package/lib/asserts/string/uuidV3.d.ts +21 -0
- package/lib/asserts/string/uuidV3.js +23 -0
- package/lib/asserts/string/uuidV3.js.map +1 -0
- package/lib/asserts/string/uuidV3.mjs +23 -0
- package/lib/asserts/string/uuidV3.mjs.map +1 -0
- package/lib/asserts/string/uuidV4.d.mts +23 -0
- package/lib/asserts/string/uuidV4.d.ts +23 -0
- package/lib/asserts/string/uuidV4.js +23 -0
- package/lib/asserts/string/uuidV4.js.map +1 -0
- package/lib/asserts/string/uuidV4.mjs +23 -0
- package/lib/asserts/string/uuidV4.mjs.map +1 -0
- package/lib/asserts/string/uuidV5.d.mts +21 -0
- package/lib/asserts/string/uuidV5.d.ts +21 -0
- package/lib/asserts/string/uuidV5.js +23 -0
- package/lib/asserts/string/uuidV5.js.map +1 -0
- package/lib/asserts/string/uuidV5.mjs +23 -0
- package/lib/asserts/string/uuidV5.mjs.map +1 -0
- package/lib/asserts/string/validUrl.d.mts +23 -0
- package/lib/asserts/string/validUrl.d.ts +23 -0
- package/lib/asserts/string/validUrl.js +32 -0
- package/lib/asserts/string/validUrl.js.map +1 -0
- package/lib/asserts/string/validUrl.mjs +32 -0
- package/lib/asserts/string/validUrl.mjs.map +1 -0
- package/lib/{chunk-NTC2XQ36.mjs → chunk-32RSTOZ4.mjs} +2 -2
- package/lib/chunk-42J6CHIO.js +7 -0
- package/lib/chunk-42J6CHIO.js.map +1 -0
- package/lib/chunk-ASZW6XRM.mjs +7 -0
- package/lib/chunk-ASZW6XRM.mjs.map +1 -0
- package/lib/{chunk-FTLRX2XG.mjs → chunk-JPRCULRQ.mjs} +12 -1
- package/lib/chunk-JPRCULRQ.mjs.map +1 -0
- package/lib/{chunk-RQH4LXBW.js → chunk-KQKJASVB.js} +12 -1
- package/lib/chunk-KQKJASVB.js.map +1 -0
- package/lib/{chunk-F5MSBL33.js → chunk-LEQCDD66.js} +12 -1
- package/lib/chunk-LEQCDD66.js.map +1 -0
- package/lib/{chunk-CLG3QRZC.mjs → chunk-P7IXNCJG.mjs} +12 -1
- package/lib/chunk-P7IXNCJG.mjs.map +1 -0
- package/lib/{chunk-B6TFELXR.mjs → chunk-PXBAS3GA.mjs} +2 -2
- package/lib/{chunk-4RNK3I74.js → chunk-RD6TBCPQ.js} +3 -3
- package/lib/{chunk-4RNK3I74.js.map → chunk-RD6TBCPQ.js.map} +1 -1
- package/lib/{chunk-RL4MSI7R.js → chunk-TKZ6FLLR.js} +3 -3
- package/lib/{chunk-RL4MSI7R.js.map → chunk-TKZ6FLLR.js.map} +1 -1
- package/lib/helpers/constants.d.mts +3 -0
- package/lib/helpers/constants.d.ts +3 -0
- package/lib/helpers/constants.js +7 -0
- package/lib/helpers/constants.js.map +1 -0
- package/lib/helpers/constants.mjs +7 -0
- package/lib/helpers/constants.mjs.map +1 -0
- package/lib/index.js +8 -7
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +8 -7
- package/lib/schemas/NumberSchema.d.mts +1 -0
- package/lib/schemas/NumberSchema.d.ts +1 -0
- package/lib/schemas/NumberSchema.js +3 -2
- package/lib/schemas/NumberSchema.js.map +1 -1
- package/lib/schemas/NumberSchema.mjs +2 -1
- package/lib/schemas/StringSchema.d.mts +1 -0
- package/lib/schemas/StringSchema.d.ts +1 -0
- package/lib/schemas/StringSchema.js +3 -2
- package/lib/schemas/StringSchema.js.map +1 -1
- package/lib/schemas/StringSchema.mjs +2 -1
- package/package.json +1 -1
- package/lib/chunk-CLG3QRZC.mjs.map +0 -1
- package/lib/chunk-F5MSBL33.js.map +0 -1
- package/lib/chunk-FTLRX2XG.mjs.map +0 -1
- package/lib/chunk-RQH4LXBW.js.map +0 -1
- /package/lib/{chunk-NTC2XQ36.mjs.map → chunk-32RSTOZ4.mjs.map} +0 -0
- /package/lib/{chunk-B6TFELXR.mjs.map → chunk-PXBAS3GA.mjs.map} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk5BVJ6YMHjs = require('../../chunk-5BVJ6YMH.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWK4O3HH4js = require('../../chunk-WK4O3HH4.js');
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/lowerCase.ts
|
|
9
|
+
var lowerCaseErrorMessage = "The received value is not in lowercase";
|
|
10
|
+
var lowerCaseErrorKey = "s:lowerCase";
|
|
11
|
+
var lowerCase = () => (received, ctx) => {
|
|
12
|
+
if (received !== received.toLowerCase()) _chunkWK4O3HH4js.guardException.call(void 0, "lower case", received, ctx, lowerCaseErrorKey);
|
|
13
|
+
};
|
|
14
|
+
lowerCase.key = lowerCaseErrorKey;
|
|
15
|
+
lowerCase.message = lowerCaseErrorMessage;
|
|
16
|
+
_chunk5BVJ6YMHjs.setToDefaultLocale.call(void 0, lowerCase);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.lowerCase = lowerCase;
|
|
20
|
+
//# sourceMappingURL=lowerCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/lowerCase.js","../../../src/asserts/string/lowerCase.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,sBAAA,EAAwB,wCAAA;AAC9B,IAAM,kBAAA,EAAoB,aAAA;AAanB,IAAM,UAAA,EAAY,CAAA,EAAA,GAA0B,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC9F,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,CAAS,WAAA,CAAY,CAAA,EAAG,6CAAA,YAAe,EAAc,QAAA,EAAU,GAAA,EAAK,iBAAiB,CAAA;AACxG,CAAA;AAEA,SAAA,CAAU,IAAA,EAAM,iBAAA;AAChB,SAAA,CAAU,QAAA,EAAU,qBAAA;AACpB,iDAAA,SAA4B,CAAA;ADR5B;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/lowerCase.js","sourcesContent":[null,"import { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { guardException } from '../../exceptions';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst lowerCaseErrorMessage = 'The received value is not in lowercase';\nconst lowerCaseErrorKey = 's:lowerCase';\n\n/**\n * @description Asserts that a string value is in lowercase.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value is not in lowercase.\n * @example\n * const schema = string().custom(lowerCase());\n * parseOrFail(schema, 'valid'); // Valid\n * parseOrFail(schema, 'Invalid'); // Throws an error: 'The received value is not in lowercase'\n *\n * @translation Error Translation Key = 's:lowerCase'\n */\nexport const lowerCase = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n if (received !== received.toLowerCase()) guardException('lower case', received, ctx, lowerCaseErrorKey);\n};\n\nlowerCase.key = lowerCaseErrorKey;\nlowerCase.message = lowerCaseErrorMessage;\nsetToDefaultLocale(lowerCase);\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setToDefaultLocale
|
|
3
|
+
} from "../../chunk-3HTYHE2X.mjs";
|
|
4
|
+
import {
|
|
5
|
+
guardException
|
|
6
|
+
} from "../../chunk-7XFLH6R2.mjs";
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/lowerCase.ts
|
|
9
|
+
var lowerCaseErrorMessage = "The received value is not in lowercase";
|
|
10
|
+
var lowerCaseErrorKey = "s:lowerCase";
|
|
11
|
+
var lowerCase = () => (received, ctx) => {
|
|
12
|
+
if (received !== received.toLowerCase()) guardException("lower case", received, ctx, lowerCaseErrorKey);
|
|
13
|
+
};
|
|
14
|
+
lowerCase.key = lowerCaseErrorKey;
|
|
15
|
+
lowerCase.message = lowerCaseErrorMessage;
|
|
16
|
+
setToDefaultLocale(lowerCase);
|
|
17
|
+
export {
|
|
18
|
+
lowerCase
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=lowerCase.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/lowerCase.ts"],"sourcesContent":["import { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { guardException } from '../../exceptions';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst lowerCaseErrorMessage = 'The received value is not in lowercase';\nconst lowerCaseErrorKey = 's:lowerCase';\n\n/**\n * @description Asserts that a string value is in lowercase.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value is not in lowercase.\n * @example\n * const schema = string().custom(lowerCase());\n * parseOrFail(schema, 'valid'); // Valid\n * parseOrFail(schema, 'Invalid'); // Throws an error: 'The received value is not in lowercase'\n *\n * @translation Error Translation Key = 's:lowerCase'\n */\nexport const lowerCase = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n if (received !== received.toLowerCase()) guardException('lower case', received, ctx, lowerCaseErrorKey);\n};\n\nlowerCase.key = lowerCaseErrorKey;\nlowerCase.message = lowerCaseErrorMessage;\nsetToDefaultLocale(lowerCase);\n"],"mappings":";;;;;;;;AAIA,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAanB,IAAM,YAAY,MAA0B,CAAC,UAAkB,QAA0B;AAC9F,MAAI,aAAa,SAAS,YAAY,EAAG,gBAAe,cAAc,UAAU,KAAK,iBAAiB;AACxG;AAEA,UAAU,MAAM;AAChB,UAAU,UAAU;AACpB,mBAAmB,SAAS;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { RequiredValidation } from '../../commonTypes.mjs';
|
|
|
3
3
|
/**
|
|
4
4
|
* @description Asserts that the length of a string value is not greater than a specified maximum length.
|
|
5
5
|
* @param {number} expected The maximum allowed length for the string.
|
|
6
|
-
* @returns {RequiredValidation} A validation function that takes a received string and
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
7
|
* @throws {ValidationError} if the length of the received value is greater than the expected length.
|
|
8
8
|
* @example
|
|
9
9
|
* const schema = string().custom(maxLength(10));
|
|
@@ -3,7 +3,7 @@ import { RequiredValidation } from '../../commonTypes.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @description Asserts that the length of a string value is not greater than a specified maximum length.
|
|
5
5
|
* @param {number} expected The maximum allowed length for the string.
|
|
6
|
-
* @returns {RequiredValidation} A validation function that takes a received string and
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
7
|
* @throws {ValidationError} if the length of the received value is greater than the expected length.
|
|
8
8
|
* @example
|
|
9
9
|
* const schema = string().custom(maxLength(10));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/maxLength.js","../../../src/asserts/string/maxLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,sBAAA,EAAwB,oDAAA;AAC9B,IAAM,kBAAA,EAAoB,aAAA;AAcnB,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,qBAAqB,CAAA;AAC/F,CAAA;AAEF,SAAA,CAAU,IAAA,EAAM,iBAAA;AAChB,SAAA,CAAU,QAAA,EAAU,qBAAA;AACpB,iDAAA,SAA4B,CAAA;ADX5B;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/maxLength.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst maxLengthErrorMessage = 'The received value length is greater than expected';\nconst maxLengthErrorKey = 's:maxLength';\n\n/**\n * @description Asserts that the length of a string value is not greater than a specified maximum length.\n * @param {number} expected The maximum allowed length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/maxLength.js","../../../src/asserts/string/maxLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,sBAAA,EAAwB,oDAAA;AAC9B,IAAM,kBAAA,EAAoB,aAAA;AAcnB,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,qBAAqB,CAAA;AAC/F,CAAA;AAEF,SAAA,CAAU,IAAA,EAAM,iBAAA;AAChB,SAAA,CAAU,QAAA,EAAU,qBAAA;AACpB,iDAAA,SAA4B,CAAA;ADX5B;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/maxLength.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst maxLengthErrorMessage = 'The received value length is greater than expected';\nconst maxLengthErrorKey = 's:maxLength';\n\n/**\n * @description Asserts that the length of a string value is not greater than a specified maximum length.\n * @param {number} expected The maximum allowed length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the length of the received value is greater than the expected length.\n * @example\n * const schema = string().custom(maxLength(10));\n * parseOrFail(schema, 'short'); // Valid\n * parseOrFail(schema, 'this is a very long string'); // Throws an error: 'The received value length is greater than expected'\n *\n * @translation Error Translation Key = 's:maxLength'\n */\nexport const maxLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length > expected) guardException(expected, received, ctx, maxLengthErrorMessage);\n };\n\nmaxLength.key = maxLengthErrorKey;\nmaxLength.message = maxLengthErrorMessage;\nsetToDefaultLocale(maxLength);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/asserts/string/maxLength.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst maxLengthErrorMessage = 'The received value length is greater than expected';\nconst maxLengthErrorKey = 's:maxLength';\n\n/**\n * @description Asserts that the length of a string value is not greater than a specified maximum length.\n * @param {number} expected The maximum allowed length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/maxLength.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst maxLengthErrorMessage = 'The received value length is greater than expected';\nconst maxLengthErrorKey = 's:maxLength';\n\n/**\n * @description Asserts that the length of a string value is not greater than a specified maximum length.\n * @param {number} expected The maximum allowed length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the length of the received value is greater than the expected length.\n * @example\n * const schema = string().custom(maxLength(10));\n * parseOrFail(schema, 'short'); // Valid\n * parseOrFail(schema, 'this is a very long string'); // Throws an error: 'The received value length is greater than expected'\n *\n * @translation Error Translation Key = 's:maxLength'\n */\nexport const maxLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length > expected) guardException(expected, received, ctx, maxLengthErrorMessage);\n };\n\nmaxLength.key = maxLengthErrorKey;\nmaxLength.message = maxLengthErrorMessage;\nsetToDefaultLocale(maxLength);\n"],"mappings":";;;;;;;;AAIA,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAcnB,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,SAAS,SAAS,SAAU,gBAAe,UAAU,UAAU,KAAK,qBAAqB;AAC/F;AAEF,UAAU,MAAM;AAChB,UAAU,UAAU;AACpB,mBAAmB,SAAS;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { RequiredValidation } from '../../commonTypes.mjs';
|
|
|
3
3
|
/**
|
|
4
4
|
* @description Asserts that the length of a string value is not less than a specified minimum length.
|
|
5
5
|
* @param {number} expected The minimum required length for the string.
|
|
6
|
-
* @returns {RequiredValidation} A validation function that takes a received string and
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
7
|
* @throws {ValidationError} if the length of the received value is less than the expected length.
|
|
8
8
|
* @example
|
|
9
9
|
* const schema = string().custom(minLength(5));
|
|
@@ -3,7 +3,7 @@ import { RequiredValidation } from '../../commonTypes.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @description Asserts that the length of a string value is not less than a specified minimum length.
|
|
5
5
|
* @param {number} expected The minimum required length for the string.
|
|
6
|
-
* @returns {RequiredValidation} A validation function that takes a received string and
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
7
|
* @throws {ValidationError} if the length of the received value is less than the expected length.
|
|
8
8
|
* @example
|
|
9
9
|
* const schema = string().custom(minLength(5));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","../../../src/asserts/string/minLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,sBAAA,EAAwB,iDAAA;AAC9B,IAAM,kBAAA,EAAoB,aAAA;AAcnB,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,qBAAqB,CAAA;AAC/F,CAAA;AAEF,SAAA,CAAU,IAAA,EAAM,iBAAA;AAChB,SAAA,CAAU,QAAA,EAAU,qBAAA;AACpB,iDAAA,SAA4B,CAAA;ADX5B;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst minLengthErrorMessage = 'The received value length is less than expected';\nconst minLengthErrorKey = 's:minLength';\n\n/**\n * @description Asserts that the length of a string value is not less than a specified minimum length.\n * @param {number} expected The minimum required length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","../../../src/asserts/string/minLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,sBAAA,EAAwB,iDAAA;AAC9B,IAAM,kBAAA,EAAoB,aAAA;AAcnB,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,qBAAqB,CAAA;AAC/F,CAAA;AAEF,SAAA,CAAU,IAAA,EAAM,iBAAA;AAChB,SAAA,CAAU,QAAA,EAAU,qBAAA;AACpB,iDAAA,SAA4B,CAAA;ADX5B;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst minLengthErrorMessage = 'The received value length is less than expected';\nconst minLengthErrorKey = 's:minLength';\n\n/**\n * @description Asserts that the length of a string value is not less than a specified minimum length.\n * @param {number} expected The minimum required length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the length of the received value is less than the expected length.\n * @example\n * const schema = string().custom(minLength(5));\n * parseOrFail(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseOrFail(schema, 'adequate'); // Valid\n *\n * @translation Error Translation Key = 's:minLength'\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length < expected) guardException(expected, received, ctx, minLengthErrorMessage);\n };\n\nminLength.key = minLengthErrorKey;\nminLength.message = minLengthErrorMessage;\nsetToDefaultLocale(minLength);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/asserts/string/minLength.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst minLengthErrorMessage = 'The received value length is less than expected';\nconst minLengthErrorKey = 's:minLength';\n\n/**\n * @description Asserts that the length of a string value is not less than a specified minimum length.\n * @param {number} expected The minimum required length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/minLength.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst minLengthErrorMessage = 'The received value length is less than expected';\nconst minLengthErrorKey = 's:minLength';\n\n/**\n * @description Asserts that the length of a string value is not less than a specified minimum length.\n * @param {number} expected The minimum required length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the length of the received value is less than the expected length.\n * @example\n * const schema = string().custom(minLength(5));\n * parseOrFail(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseOrFail(schema, 'adequate'); // Valid\n *\n * @translation Error Translation Key = 's:minLength'\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length < expected) guardException(expected, received, ctx, minLengthErrorMessage);\n };\n\nminLength.key = minLengthErrorKey;\nminLength.message = minLengthErrorMessage;\nsetToDefaultLocale(minLength);\n"],"mappings":";;;;;;;;AAIA,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAcnB,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,SAAS,SAAS,SAAU,gBAAe,UAAU,UAAU,KAAK,qBAAqB;AAC/F;AAEF,UAAU,MAAM;AAChB,UAAU,UAAU;AACpB,mBAAmB,SAAS;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { RequiredValidation } from '../../commonTypes.mjs';
|
|
|
3
3
|
/**
|
|
4
4
|
* @description Asserts that a string value matches a specified regular expression pattern.
|
|
5
5
|
* @param {RegExp} expected The regular expression pattern that the string value should match.
|
|
6
|
-
* @returns {RequiredValidation} A validation function that takes a received string and
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
7
|
* @throws {ValidationError} if the received value does not match the expected pattern.
|
|
8
8
|
* @example
|
|
9
9
|
* const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern
|
|
@@ -3,7 +3,7 @@ import { RequiredValidation } from '../../commonTypes.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @description Asserts that a string value matches a specified regular expression pattern.
|
|
5
5
|
* @param {RegExp} expected The regular expression pattern that the string value should match.
|
|
6
|
-
* @returns {RequiredValidation} A validation function that takes a received string and
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
7
|
* @throws {ValidationError} if the received value does not match the expected pattern.
|
|
8
8
|
* @example
|
|
9
9
|
* const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","../../../src/asserts/string/regExp.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,mBAAA,EAAqB,6DAAA;AAC3B,IAAM,eAAA,EAAiB,UAAA;AAchB,IAAM,OAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,kBAAkB,CAAA;AAC1F,CAAA;AAEF,MAAA,CAAO,IAAA,EAAM,cAAA;AACb,MAAA,CAAO,QAAA,EAAU,kBAAA;AACjB,iDAAA,MAAyB,CAAA;ADXzB;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","sourcesContent":[null,"import { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { guardException } from '../../exceptions';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst regExpErrorMessage = 'The received value does not match the required text pattern';\nconst regExpErrorKey = 's:regExp';\n\n/**\n * @description Asserts that a string value matches a specified regular expression pattern.\n * @param {RegExp} expected The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} A validation function that takes a received string and
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","../../../src/asserts/string/regExp.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,mBAAA,EAAqB,6DAAA;AAC3B,IAAM,eAAA,EAAiB,UAAA;AAchB,IAAM,OAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,kBAAkB,CAAA;AAC1F,CAAA;AAEF,MAAA,CAAO,IAAA,EAAM,cAAA;AACb,MAAA,CAAO,QAAA,EAAU,kBAAA;AACjB,iDAAA,MAAyB,CAAA;ADXzB;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","sourcesContent":[null,"import { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { guardException } from '../../exceptions';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst regExpErrorMessage = 'The received value does not match the required text pattern';\nconst regExpErrorKey = 's:regExp';\n\n/**\n * @description Asserts that a string value matches a specified regular expression pattern.\n * @param {RegExp} expected The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not match the expected pattern.\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseOrFail(schema, 'valid123'); // Valid\n * parseOrFail(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n *\n * @translation Error Translation Key = 's:regExp'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (!expected.test(received)) guardException(expected, received, ctx, regExpErrorMessage);\n };\n\nregExp.key = regExpErrorKey;\nregExp.message = regExpErrorMessage;\nsetToDefaultLocale(regExp);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/asserts/string/regExp.ts"],"sourcesContent":["import { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { guardException } from '../../exceptions';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst regExpErrorMessage = 'The received value does not match the required text pattern';\nconst regExpErrorKey = 's:regExp';\n\n/**\n * @description Asserts that a string value matches a specified regular expression pattern.\n * @param {RegExp} expected The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} A validation function that takes a received string and
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/regExp.ts"],"sourcesContent":["import { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { guardException } from '../../exceptions';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst regExpErrorMessage = 'The received value does not match the required text pattern';\nconst regExpErrorKey = 's:regExp';\n\n/**\n * @description Asserts that a string value matches a specified regular expression pattern.\n * @param {RegExp} expected The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not match the expected pattern.\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseOrFail(schema, 'valid123'); // Valid\n * parseOrFail(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n *\n * @translation Error Translation Key = 's:regExp'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (!expected.test(received)) guardException(expected, received, ctx, regExpErrorMessage);\n };\n\nregExp.key = regExpErrorKey;\nregExp.message = regExpErrorMessage;\nsetToDefaultLocale(regExp);\n"],"mappings":";;;;;;;;AAIA,IAAM,qBAAqB;AAC3B,IAAM,iBAAiB;AAchB,IAAM,SACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,CAAC,SAAS,KAAK,QAAQ,EAAG,gBAAe,UAAU,UAAU,KAAK,kBAAkB;AAC1F;AAEF,OAAO,MAAM;AACb,OAAO,UAAU;AACjB,mBAAmB,MAAM;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that a string value starts with a specified substring.
|
|
5
|
+
* @param {string} substring The substring that the string value must start with.
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
|
+
* @throws {ValidationError} if the received value does not start with the required substring.
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = string().custom(startsWith('foo'));
|
|
10
|
+
* parseOrFail(schema, 'foobar'); // Valid
|
|
11
|
+
* parseOrFail(schema, 'barfoo'); // Throws an error: 'The received value does not start with the required substring'
|
|
12
|
+
*
|
|
13
|
+
* @translation Error Translation Key = 's:startsWith'
|
|
14
|
+
*/
|
|
15
|
+
declare const startsWith: {
|
|
16
|
+
(substring: string): RequiredValidation;
|
|
17
|
+
key: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { startsWith };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that a string value starts with a specified substring.
|
|
5
|
+
* @param {string} substring The substring that the string value must start with.
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
|
+
* @throws {ValidationError} if the received value does not start with the required substring.
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = string().custom(startsWith('foo'));
|
|
10
|
+
* parseOrFail(schema, 'foobar'); // Valid
|
|
11
|
+
* parseOrFail(schema, 'barfoo'); // Throws an error: 'The received value does not start with the required substring'
|
|
12
|
+
*
|
|
13
|
+
* @translation Error Translation Key = 's:startsWith'
|
|
14
|
+
*/
|
|
15
|
+
declare const startsWith: {
|
|
16
|
+
(substring: string): RequiredValidation;
|
|
17
|
+
key: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { startsWith };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk5BVJ6YMHjs = require('../../chunk-5BVJ6YMH.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWK4O3HH4js = require('../../chunk-WK4O3HH4.js');
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/startsWith.ts
|
|
9
|
+
var startsWithErrorMessage = "The received value does not start with the required substring";
|
|
10
|
+
var startsWithErrorKey = "s:startsWith";
|
|
11
|
+
var startsWith = (substring) => (received, ctx) => {
|
|
12
|
+
if (!received.startsWith(substring)) {
|
|
13
|
+
_chunkWK4O3HH4js.guardException.call(void 0, `starts with '${substring}'`, received, ctx, startsWithErrorKey);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
startsWith.key = startsWithErrorKey;
|
|
17
|
+
startsWith.message = startsWithErrorMessage;
|
|
18
|
+
_chunk5BVJ6YMHjs.setToDefaultLocale.call(void 0, startsWith);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.startsWith = startsWith;
|
|
22
|
+
//# sourceMappingURL=startsWith.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/startsWith.js","../../../src/asserts/string/startsWith.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,uBAAA,EAAyB,+DAAA;AAC/B,IAAM,mBAAA,EAAqB,cAAA;AAcpB,IAAM,WAAA,EACX,CAAC,SAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,UAAA,CAAW,SAAS,CAAA,EAAG;AACnC,IAAA,6CAAA,CAAe,aAAA,EAAgB,SAAS,CAAA,CAAA,CAAA,EAAK,QAAA,EAAU,GAAA,EAAK,kBAAkB,CAAA;AAAA,EAChF;AACF,CAAA;AAEF,UAAA,CAAW,IAAA,EAAM,kBAAA;AACjB,UAAA,CAAW,QAAA,EAAU,sBAAA;AACrB,iDAAA,UAA6B,CAAA;ADX7B;AACE;AACF,gCAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/startsWith.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst startsWithErrorMessage = 'The received value does not start with the required substring';\nconst startsWithErrorKey = 's:startsWith';\n\n/**\n * @description Asserts that a string value starts with a specified substring.\n * @param {string} substring The substring that the string value must start with.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not start with the required substring.\n * @example\n * const schema = string().custom(startsWith('foo'));\n * parseOrFail(schema, 'foobar'); // Valid\n * parseOrFail(schema, 'barfoo'); // Throws an error: 'The received value does not start with the required substring'\n *\n * @translation Error Translation Key = 's:startsWith'\n */\nexport const startsWith =\n (substring: string): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (!received.startsWith(substring)) {\n guardException(`starts with '${substring}'`, received, ctx, startsWithErrorKey);\n }\n };\n\nstartsWith.key = startsWithErrorKey;\nstartsWith.message = startsWithErrorMessage;\nsetToDefaultLocale(startsWith);\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setToDefaultLocale
|
|
3
|
+
} from "../../chunk-3HTYHE2X.mjs";
|
|
4
|
+
import {
|
|
5
|
+
guardException
|
|
6
|
+
} from "../../chunk-7XFLH6R2.mjs";
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/startsWith.ts
|
|
9
|
+
var startsWithErrorMessage = "The received value does not start with the required substring";
|
|
10
|
+
var startsWithErrorKey = "s:startsWith";
|
|
11
|
+
var startsWith = (substring) => (received, ctx) => {
|
|
12
|
+
if (!received.startsWith(substring)) {
|
|
13
|
+
guardException(`starts with '${substring}'`, received, ctx, startsWithErrorKey);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
startsWith.key = startsWithErrorKey;
|
|
17
|
+
startsWith.message = startsWithErrorMessage;
|
|
18
|
+
setToDefaultLocale(startsWith);
|
|
19
|
+
export {
|
|
20
|
+
startsWith
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=startsWith.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/startsWith.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst startsWithErrorMessage = 'The received value does not start with the required substring';\nconst startsWithErrorKey = 's:startsWith';\n\n/**\n * @description Asserts that a string value starts with a specified substring.\n * @param {string} substring The substring that the string value must start with.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not start with the required substring.\n * @example\n * const schema = string().custom(startsWith('foo'));\n * parseOrFail(schema, 'foobar'); // Valid\n * parseOrFail(schema, 'barfoo'); // Throws an error: 'The received value does not start with the required substring'\n *\n * @translation Error Translation Key = 's:startsWith'\n */\nexport const startsWith =\n (substring: string): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (!received.startsWith(substring)) {\n guardException(`starts with '${substring}'`, received, ctx, startsWithErrorKey);\n }\n };\n\nstartsWith.key = startsWithErrorKey;\nstartsWith.message = startsWithErrorMessage;\nsetToDefaultLocale(startsWith);\n"],"mappings":";;;;;;;;AAIA,IAAM,yBAAyB;AAC/B,IAAM,qBAAqB;AAcpB,IAAM,aACX,CAAC,cACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,CAAC,SAAS,WAAW,SAAS,GAAG;AACnC,mBAAe,gBAAgB,SAAS,KAAK,UAAU,KAAK,kBAAkB;AAAA,EAChF;AACF;AAEF,WAAW,MAAM;AACjB,WAAW,UAAU;AACrB,mBAAmB,UAAU;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that a string value is entirely in uppercase.
|
|
5
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
6
|
+
* @throws {ValidationError} if the received value is not in uppercase.
|
|
7
|
+
* @example
|
|
8
|
+
* const schema = string().custom(upperCase());
|
|
9
|
+
* parseOrFail(schema, 'VALID'); // Valid
|
|
10
|
+
* parseOrFail(schema, 'INVALID'); // Throws an error: 'The received value is not in uppercase'
|
|
11
|
+
* parseOrFail(schema, 'Valid'); // Throws an error: 'The received value is not in uppercase'
|
|
12
|
+
*
|
|
13
|
+
* @translation Error Translation Key = 's:upperCase'
|
|
14
|
+
*/
|
|
15
|
+
declare const upperCase: {
|
|
16
|
+
(): RequiredValidation;
|
|
17
|
+
key: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { upperCase };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that a string value is entirely in uppercase.
|
|
5
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
6
|
+
* @throws {ValidationError} if the received value is not in uppercase.
|
|
7
|
+
* @example
|
|
8
|
+
* const schema = string().custom(upperCase());
|
|
9
|
+
* parseOrFail(schema, 'VALID'); // Valid
|
|
10
|
+
* parseOrFail(schema, 'INVALID'); // Throws an error: 'The received value is not in uppercase'
|
|
11
|
+
* parseOrFail(schema, 'Valid'); // Throws an error: 'The received value is not in uppercase'
|
|
12
|
+
*
|
|
13
|
+
* @translation Error Translation Key = 's:upperCase'
|
|
14
|
+
*/
|
|
15
|
+
declare const upperCase: {
|
|
16
|
+
(): RequiredValidation;
|
|
17
|
+
key: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { upperCase };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk5BVJ6YMHjs = require('../../chunk-5BVJ6YMH.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWK4O3HH4js = require('../../chunk-WK4O3HH4.js');
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/upperCase.ts
|
|
9
|
+
var upperCaseErrorMessage = "The received value is not in uppercase";
|
|
10
|
+
var upperCaseErrorKey = "s:upperCase";
|
|
11
|
+
var upperCase = () => (received, ctx) => {
|
|
12
|
+
if (received !== received.toUpperCase()) {
|
|
13
|
+
_chunkWK4O3HH4js.guardException.call(void 0, "upper case", received, ctx, upperCaseErrorKey);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
upperCase.key = upperCaseErrorKey;
|
|
17
|
+
upperCase.message = upperCaseErrorMessage;
|
|
18
|
+
_chunk5BVJ6YMHjs.setToDefaultLocale.call(void 0, upperCase);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.upperCase = upperCase;
|
|
22
|
+
//# sourceMappingURL=upperCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/upperCase.js","../../../src/asserts/string/upperCase.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,sBAAA,EAAwB,wCAAA;AAC9B,IAAM,kBAAA,EAAoB,aAAA;AAcnB,IAAM,UAAA,EAAY,CAAA,EAAA,GAA0B,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC9F,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,CAAS,WAAA,CAAY,CAAA,EAAG;AACvC,IAAA,6CAAA,YAAe,EAAc,QAAA,EAAU,GAAA,EAAK,iBAAiB,CAAA;AAAA,EAC/D;AACF,CAAA;AAEA,SAAA,CAAU,IAAA,EAAM,iBAAA;AAChB,SAAA,CAAU,QAAA,EAAU,qBAAA;AACpB,iDAAA,SAA4B,CAAA;ADT5B;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/upperCase.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst upperCaseErrorMessage = 'The received value is not in uppercase';\nconst upperCaseErrorKey = 's:upperCase';\n\n/**\n * @description Asserts that a string value is entirely in uppercase.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value is not in uppercase.\n * @example\n * const schema = string().custom(upperCase());\n * parseOrFail(schema, 'VALID'); // Valid\n * parseOrFail(schema, 'INVALID'); // Throws an error: 'The received value is not in uppercase'\n * parseOrFail(schema, 'Valid'); // Throws an error: 'The received value is not in uppercase'\n *\n * @translation Error Translation Key = 's:upperCase'\n */\nexport const upperCase = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n if (received !== received.toUpperCase()) {\n guardException('upper case', received, ctx, upperCaseErrorKey);\n }\n};\n\nupperCase.key = upperCaseErrorKey;\nupperCase.message = upperCaseErrorMessage;\nsetToDefaultLocale(upperCase);\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setToDefaultLocale
|
|
3
|
+
} from "../../chunk-3HTYHE2X.mjs";
|
|
4
|
+
import {
|
|
5
|
+
guardException
|
|
6
|
+
} from "../../chunk-7XFLH6R2.mjs";
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/upperCase.ts
|
|
9
|
+
var upperCaseErrorMessage = "The received value is not in uppercase";
|
|
10
|
+
var upperCaseErrorKey = "s:upperCase";
|
|
11
|
+
var upperCase = () => (received, ctx) => {
|
|
12
|
+
if (received !== received.toUpperCase()) {
|
|
13
|
+
guardException("upper case", received, ctx, upperCaseErrorKey);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
upperCase.key = upperCaseErrorKey;
|
|
17
|
+
upperCase.message = upperCaseErrorMessage;
|
|
18
|
+
setToDefaultLocale(upperCase);
|
|
19
|
+
export {
|
|
20
|
+
upperCase
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=upperCase.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/upperCase.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst upperCaseErrorMessage = 'The received value is not in uppercase';\nconst upperCaseErrorKey = 's:upperCase';\n\n/**\n * @description Asserts that a string value is entirely in uppercase.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value is not in uppercase.\n * @example\n * const schema = string().custom(upperCase());\n * parseOrFail(schema, 'VALID'); // Valid\n * parseOrFail(schema, 'INVALID'); // Throws an error: 'The received value is not in uppercase'\n * parseOrFail(schema, 'Valid'); // Throws an error: 'The received value is not in uppercase'\n *\n * @translation Error Translation Key = 's:upperCase'\n */\nexport const upperCase = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n if (received !== received.toUpperCase()) {\n guardException('upper case', received, ctx, upperCaseErrorKey);\n }\n};\n\nupperCase.key = upperCaseErrorKey;\nupperCase.message = upperCaseErrorMessage;\nsetToDefaultLocale(upperCase);\n"],"mappings":";;;;;;;;AAIA,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAcnB,IAAM,YAAY,MAA0B,CAAC,UAAkB,QAA0B;AAC9F,MAAI,aAAa,SAAS,YAAY,GAAG;AACvC,mBAAe,cAAc,UAAU,KAAK,iBAAiB;AAAA,EAC/D;AACF;AAEA,UAAU,MAAM;AAChB,UAAU,UAAU;AACpB,mBAAmB,SAAS;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that a string value matches the UUID format.
|
|
5
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
6
|
+
* @throws {ValidationError} if the received value is not a valid UUID.
|
|
7
|
+
* @example
|
|
8
|
+
* const schema = string().custom(uuid());
|
|
9
|
+
* parseOrFail(schema, '123e4567-e89b-12d3-a456-426614174000'); // Valid
|
|
10
|
+
* parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID'
|
|
11
|
+
*
|
|
12
|
+
* @translation Error Translation Key = 's:uuid'
|
|
13
|
+
*/
|
|
14
|
+
declare const uuid: {
|
|
15
|
+
(): RequiredValidation;
|
|
16
|
+
key: string;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { uuid };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that a string value matches the UUID format.
|
|
5
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
6
|
+
* @throws {ValidationError} if the received value is not a valid UUID.
|
|
7
|
+
* @example
|
|
8
|
+
* const schema = string().custom(uuid());
|
|
9
|
+
* parseOrFail(schema, '123e4567-e89b-12d3-a456-426614174000'); // Valid
|
|
10
|
+
* parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID'
|
|
11
|
+
*
|
|
12
|
+
* @translation Error Translation Key = 's:uuid'
|
|
13
|
+
*/
|
|
14
|
+
declare const uuid: {
|
|
15
|
+
(): RequiredValidation;
|
|
16
|
+
key: string;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { uuid };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk5BVJ6YMHjs = require('../../chunk-5BVJ6YMH.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWK4O3HH4js = require('../../chunk-WK4O3HH4.js');
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/uuid.ts
|
|
9
|
+
var uuidErrorMessage = "The received value is not a valid UUID";
|
|
10
|
+
var uuidErrorKey = "s:uuid";
|
|
11
|
+
var uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
12
|
+
var uuid = () => (received, ctx) => {
|
|
13
|
+
if (!uuidPattern.test(received)) {
|
|
14
|
+
_chunkWK4O3HH4js.guardException.call(void 0, "uuid", received, ctx, uuidErrorKey);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
uuid.key = uuidErrorKey;
|
|
18
|
+
uuid.message = uuidErrorMessage;
|
|
19
|
+
_chunk5BVJ6YMHjs.setToDefaultLocale.call(void 0, uuid);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
exports.uuid = uuid;
|
|
23
|
+
//# sourceMappingURL=uuid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/uuid.js","../../../src/asserts/string/uuid.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,iBAAA,EAAmB,wCAAA;AACzB,IAAM,aAAA,EAAe,QAAA;AAErB,IAAM,YAAA,EAAc,iEAAA;AAab,IAAM,KAAA,EAAO,CAAA,EAAA,GAA0B,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AACzF,EAAA,GAAA,CAAI,CAAC,WAAA,CAAY,IAAA,CAAK,QAAQ,CAAA,EAAG;AAC/B,IAAA,6CAAA,MAAe,EAAQ,QAAA,EAAU,GAAA,EAAK,YAAY,CAAA;AAAA,EACpD;AACF,CAAA;AAEA,IAAA,CAAK,IAAA,EAAM,YAAA;AACX,IAAA,CAAK,QAAA,EAAU,gBAAA;AACf,iDAAA,IAAuB,CAAA;ADTvB;AACE;AACF,oBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/uuid.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst uuidErrorMessage = 'The received value is not a valid UUID';\nconst uuidErrorKey = 's:uuid';\n\nconst uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * @description Asserts that a string value matches the UUID format.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value is not a valid UUID.\n * @example\n * const schema = string().custom(uuid());\n * parseOrFail(schema, '123e4567-e89b-12d3-a456-426614174000'); // Valid\n * parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID'\n *\n * @translation Error Translation Key = 's:uuid'\n */\nexport const uuid = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n if (!uuidPattern.test(received)) {\n guardException('uuid', received, ctx, uuidErrorKey);\n }\n};\n\nuuid.key = uuidErrorKey;\nuuid.message = uuidErrorMessage;\nsetToDefaultLocale(uuid);\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setToDefaultLocale
|
|
3
|
+
} from "../../chunk-3HTYHE2X.mjs";
|
|
4
|
+
import {
|
|
5
|
+
guardException
|
|
6
|
+
} from "../../chunk-7XFLH6R2.mjs";
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/uuid.ts
|
|
9
|
+
var uuidErrorMessage = "The received value is not a valid UUID";
|
|
10
|
+
var uuidErrorKey = "s:uuid";
|
|
11
|
+
var uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
12
|
+
var uuid = () => (received, ctx) => {
|
|
13
|
+
if (!uuidPattern.test(received)) {
|
|
14
|
+
guardException("uuid", received, ctx, uuidErrorKey);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
uuid.key = uuidErrorKey;
|
|
18
|
+
uuid.message = uuidErrorMessage;
|
|
19
|
+
setToDefaultLocale(uuid);
|
|
20
|
+
export {
|
|
21
|
+
uuid
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=uuid.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/uuid.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst uuidErrorMessage = 'The received value is not a valid UUID';\nconst uuidErrorKey = 's:uuid';\n\nconst uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * @description Asserts that a string value matches the UUID format.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value is not a valid UUID.\n * @example\n * const schema = string().custom(uuid());\n * parseOrFail(schema, '123e4567-e89b-12d3-a456-426614174000'); // Valid\n * parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID'\n *\n * @translation Error Translation Key = 's:uuid'\n */\nexport const uuid = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n if (!uuidPattern.test(received)) {\n guardException('uuid', received, ctx, uuidErrorKey);\n }\n};\n\nuuid.key = uuidErrorKey;\nuuid.message = uuidErrorMessage;\nsetToDefaultLocale(uuid);\n"],"mappings":";;;;;;;;AAIA,IAAM,mBAAmB;AACzB,IAAM,eAAe;AAErB,IAAM,cAAc;AAab,IAAM,OAAO,MAA0B,CAAC,UAAkB,QAA0B;AACzF,MAAI,CAAC,YAAY,KAAK,QAAQ,GAAG;AAC/B,mBAAe,QAAQ,UAAU,KAAK,YAAY;AAAA,EACpD;AACF;AAEA,KAAK,MAAM;AACX,KAAK,UAAU;AACf,mBAAmB,IAAI;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that a string value matches the UUID v1 format.
|
|
5
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
6
|
+
* @throws {ValidationError} if the received value is not a valid UUID v1.
|
|
7
|
+
* @example
|
|
8
|
+
* const schema = string().custom(uuidV1());
|
|
9
|
+
* parseOrFail(schema, '550e8400-e29b-11d4-a716-446655440000'); // Valid
|
|
10
|
+
* parseOrFail(schema, '550e8400-e29b-21d4-a716-446655440000'); // Throws an error: 'The received value is not a valid UUID v1'
|
|
11
|
+
* parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID v1'
|
|
12
|
+
*
|
|
13
|
+
* @translation Error Translation Key = 's:uuidV1'
|
|
14
|
+
*/
|
|
15
|
+
declare const uuidV1: {
|
|
16
|
+
(): RequiredValidation;
|
|
17
|
+
key: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { uuidV1 };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that a string value matches the UUID v1 format.
|
|
5
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
6
|
+
* @throws {ValidationError} if the received value is not a valid UUID v1.
|
|
7
|
+
* @example
|
|
8
|
+
* const schema = string().custom(uuidV1());
|
|
9
|
+
* parseOrFail(schema, '550e8400-e29b-11d4-a716-446655440000'); // Valid
|
|
10
|
+
* parseOrFail(schema, '550e8400-e29b-21d4-a716-446655440000'); // Throws an error: 'The received value is not a valid UUID v1'
|
|
11
|
+
* parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID v1'
|
|
12
|
+
*
|
|
13
|
+
* @translation Error Translation Key = 's:uuidV1'
|
|
14
|
+
*/
|
|
15
|
+
declare const uuidV1: {
|
|
16
|
+
(): RequiredValidation;
|
|
17
|
+
key: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { uuidV1 };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk5BVJ6YMHjs = require('../../chunk-5BVJ6YMH.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWK4O3HH4js = require('../../chunk-WK4O3HH4.js');
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/uuidV1.ts
|
|
9
|
+
var uuidV1ErrorMessage = "The received value is not a valid UUID v1";
|
|
10
|
+
var uuidV1ErrorKey = "s:uuidV1";
|
|
11
|
+
var uuidV1Pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
12
|
+
var uuidV1 = () => (received, ctx) => {
|
|
13
|
+
if (!uuidV1Pattern.test(received)) {
|
|
14
|
+
_chunkWK4O3HH4js.guardException.call(void 0, "uuid v1", received, ctx, uuidV1ErrorKey);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
uuidV1.key = uuidV1ErrorKey;
|
|
18
|
+
uuidV1.message = uuidV1ErrorMessage;
|
|
19
|
+
_chunk5BVJ6YMHjs.setToDefaultLocale.call(void 0, uuidV1);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
exports.uuidV1 = uuidV1;
|
|
23
|
+
//# sourceMappingURL=uuidV1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/uuidV1.js","../../../src/asserts/string/uuidV1.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,mBAAA,EAAqB,2CAAA;AAC3B,IAAM,eAAA,EAAiB,UAAA;AAEvB,IAAM,cAAA,EAAgB,wEAAA;AAcf,IAAM,OAAA,EAAS,CAAA,EAAA,GAA0B,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3F,EAAA,GAAA,CAAI,CAAC,aAAA,CAAc,IAAA,CAAK,QAAQ,CAAA,EAAG;AACjC,IAAA,6CAAA,SAAe,EAAW,QAAA,EAAU,GAAA,EAAK,cAAc,CAAA;AAAA,EACzD;AACF,CAAA;AAEA,MAAA,CAAO,IAAA,EAAM,cAAA;AACb,MAAA,CAAO,QAAA,EAAU,kBAAA;AACjB,iDAAA,MAAyB,CAAA;ADVzB;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/uuidV1.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst uuidV1ErrorMessage = 'The received value is not a valid UUID v1';\nconst uuidV1ErrorKey = 's:uuidV1';\n\nconst uuidV1Pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\n/**\n * @description Asserts that a string value matches the UUID v1 format.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value is not a valid UUID v1.\n * @example\n * const schema = string().custom(uuidV1());\n * parseOrFail(schema, '550e8400-e29b-11d4-a716-446655440000'); // Valid\n * parseOrFail(schema, '550e8400-e29b-21d4-a716-446655440000'); // Throws an error: 'The received value is not a valid UUID v1'\n * parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID v1'\n *\n * @translation Error Translation Key = 's:uuidV1'\n */\nexport const uuidV1 = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n if (!uuidV1Pattern.test(received)) {\n guardException('uuid v1', received, ctx, uuidV1ErrorKey);\n }\n};\n\nuuidV1.key = uuidV1ErrorKey;\nuuidV1.message = uuidV1ErrorMessage;\nsetToDefaultLocale(uuidV1);\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setToDefaultLocale
|
|
3
|
+
} from "../../chunk-3HTYHE2X.mjs";
|
|
4
|
+
import {
|
|
5
|
+
guardException
|
|
6
|
+
} from "../../chunk-7XFLH6R2.mjs";
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/uuidV1.ts
|
|
9
|
+
var uuidV1ErrorMessage = "The received value is not a valid UUID v1";
|
|
10
|
+
var uuidV1ErrorKey = "s:uuidV1";
|
|
11
|
+
var uuidV1Pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
12
|
+
var uuidV1 = () => (received, ctx) => {
|
|
13
|
+
if (!uuidV1Pattern.test(received)) {
|
|
14
|
+
guardException("uuid v1", received, ctx, uuidV1ErrorKey);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
uuidV1.key = uuidV1ErrorKey;
|
|
18
|
+
uuidV1.message = uuidV1ErrorMessage;
|
|
19
|
+
setToDefaultLocale(uuidV1);
|
|
20
|
+
export {
|
|
21
|
+
uuidV1
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=uuidV1.mjs.map
|