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
|
@@ -4,16 +4,23 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
oneOfValues
|
|
6
6
|
} from "./chunk-3O4WCRC2.mjs";
|
|
7
|
+
import {
|
|
8
|
+
ONLY_ONCE
|
|
9
|
+
} from "./chunk-ASZW6XRM.mjs";
|
|
7
10
|
import {
|
|
8
11
|
_setStrictType
|
|
9
12
|
} from "./chunk-RYVUYVEE.mjs";
|
|
10
13
|
import {
|
|
11
14
|
CommonSchema
|
|
12
15
|
} from "./chunk-DPBE7TAQ.mjs";
|
|
16
|
+
import {
|
|
17
|
+
BuildSchemaError
|
|
18
|
+
} from "./chunk-7XFLH6R2.mjs";
|
|
13
19
|
|
|
14
20
|
// src/schemas/StringSchema.ts
|
|
15
21
|
var StringSchema = class extends CommonSchema {
|
|
16
22
|
_string = 1;
|
|
23
|
+
limit;
|
|
17
24
|
/**
|
|
18
25
|
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
19
26
|
*
|
|
@@ -23,6 +30,8 @@ var StringSchema = class extends CommonSchema {
|
|
|
23
30
|
* @example - string().equalTo('hello'); // Infers the type 'hello'
|
|
24
31
|
*/
|
|
25
32
|
equalTo(expectedValue) {
|
|
33
|
+
if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
|
|
34
|
+
this.limit = true;
|
|
26
35
|
_setStrictType(this, `'${expectedValue}'`);
|
|
27
36
|
return this.custom(equalTo(expectedValue));
|
|
28
37
|
}
|
|
@@ -36,6 +45,8 @@ var StringSchema = class extends CommonSchema {
|
|
|
36
45
|
* string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
|
|
37
46
|
*/
|
|
38
47
|
oneOfValues(expectedValue) {
|
|
48
|
+
if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
|
|
49
|
+
this.limit = true;
|
|
39
50
|
_setStrictType(
|
|
40
51
|
this,
|
|
41
52
|
expectedValue.map((el) => `'${el}'`)
|
|
@@ -47,4 +58,4 @@ var StringSchema = class extends CommonSchema {
|
|
|
47
58
|
export {
|
|
48
59
|
StringSchema
|
|
49
60
|
};
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-JPRCULRQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,IAAI,aAAa,GAAG;AAEzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -6,14 +6,21 @@ var _chunkJ4VKFJQKjs = require('./chunk-J4VKFJQK.js');
|
|
|
6
6
|
var _chunk4CYIMDP2js = require('./chunk-4CYIMDP2.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
|
|
10
|
+
|
|
11
|
+
|
|
9
12
|
var _chunkJSGZ7DKTjs = require('./chunk-JSGZ7DKT.js');
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
var _chunkEGEHSELTjs = require('./chunk-EGEHSELT.js');
|
|
13
16
|
|
|
17
|
+
|
|
18
|
+
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
19
|
+
|
|
14
20
|
// src/schemas/NumberSchema.ts
|
|
15
21
|
var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
16
22
|
__init() {this._number = 1}
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
19
26
|
*
|
|
@@ -23,6 +30,8 @@ var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
23
30
|
* @example - number().equalTo(42); // Infers the type 42
|
|
24
31
|
*/
|
|
25
32
|
equalTo(expectedValue) {
|
|
33
|
+
if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
34
|
+
this.limit = true;
|
|
26
35
|
_chunkJSGZ7DKTjs._setStrictType.call(void 0, this, expectedValue);
|
|
27
36
|
return this.custom(_chunkJ4VKFJQKjs.equalTo.call(void 0, expectedValue));
|
|
28
37
|
}
|
|
@@ -36,6 +45,8 @@ var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
36
45
|
* number().oneOfValues([5, 7]); // Infers the type 5 | 7
|
|
37
46
|
*/
|
|
38
47
|
oneOfValues(expectedValue) {
|
|
48
|
+
if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
49
|
+
this.limit = true;
|
|
39
50
|
_chunkJSGZ7DKTjs._setStrictType.call(void 0, this, expectedValue);
|
|
40
51
|
return this.custom(_chunk4CYIMDP2js.oneOfValues.call(void 0, expectedValue));
|
|
41
52
|
}
|
|
@@ -44,4 +55,4 @@ var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
44
55
|
|
|
45
56
|
|
|
46
57
|
exports.NumberSchema = NumberSchema;
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-KQKJASVB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-KQKJASVB.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADYA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-KQKJASVB.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"]}
|
|
@@ -6,14 +6,21 @@ var _chunkJ4VKFJQKjs = require('./chunk-J4VKFJQK.js');
|
|
|
6
6
|
var _chunk4CYIMDP2js = require('./chunk-4CYIMDP2.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
|
|
10
|
+
|
|
11
|
+
|
|
9
12
|
var _chunkJSGZ7DKTjs = require('./chunk-JSGZ7DKT.js');
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
var _chunkEGEHSELTjs = require('./chunk-EGEHSELT.js');
|
|
13
16
|
|
|
17
|
+
|
|
18
|
+
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
19
|
+
|
|
14
20
|
// src/schemas/StringSchema.ts
|
|
15
21
|
var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
16
22
|
__init() {this._string = 1}
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
19
26
|
*
|
|
@@ -23,6 +30,8 @@ var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
23
30
|
* @example - string().equalTo('hello'); // Infers the type 'hello'
|
|
24
31
|
*/
|
|
25
32
|
equalTo(expectedValue) {
|
|
33
|
+
if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
34
|
+
this.limit = true;
|
|
26
35
|
_chunkJSGZ7DKTjs._setStrictType.call(void 0, this, `'${expectedValue}'`);
|
|
27
36
|
return this.custom(_chunkJ4VKFJQKjs.equalTo.call(void 0, expectedValue));
|
|
28
37
|
}
|
|
@@ -36,6 +45,8 @@ var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
36
45
|
* string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
|
|
37
46
|
*/
|
|
38
47
|
oneOfValues(expectedValue) {
|
|
48
|
+
if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
49
|
+
this.limit = true;
|
|
39
50
|
_chunkJSGZ7DKTjs._setStrictType.call(void 0,
|
|
40
51
|
this,
|
|
41
52
|
expectedValue.map((el) => `'${el}'`)
|
|
@@ -47,4 +58,4 @@ var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
47
58
|
|
|
48
59
|
|
|
49
60
|
exports.StringSchema = StringSchema;
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-LEQCDD66.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-LEQCDD66.js","../src/schemas/StringSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,CAAG,CAAA;AAEzC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA;AAAA,MACE,IAAA;AAAA,MACA,aAAA,CAAc,GAAA,CAAI,CAAC,EAAA,EAAA,GAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG;AAAA,IACrC,CAAA;AACA,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADWA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-LEQCDD66.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"]}
|
|
@@ -4,16 +4,23 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
oneOfValues
|
|
6
6
|
} from "./chunk-3O4WCRC2.mjs";
|
|
7
|
+
import {
|
|
8
|
+
ONLY_ONCE
|
|
9
|
+
} from "./chunk-ASZW6XRM.mjs";
|
|
7
10
|
import {
|
|
8
11
|
_setStrictType
|
|
9
12
|
} from "./chunk-RYVUYVEE.mjs";
|
|
10
13
|
import {
|
|
11
14
|
CommonSchema
|
|
12
15
|
} from "./chunk-DPBE7TAQ.mjs";
|
|
16
|
+
import {
|
|
17
|
+
BuildSchemaError
|
|
18
|
+
} from "./chunk-7XFLH6R2.mjs";
|
|
13
19
|
|
|
14
20
|
// src/schemas/NumberSchema.ts
|
|
15
21
|
var NumberSchema = class extends CommonSchema {
|
|
16
22
|
_number = 1;
|
|
23
|
+
limit;
|
|
17
24
|
/**
|
|
18
25
|
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
19
26
|
*
|
|
@@ -23,6 +30,8 @@ var NumberSchema = class extends CommonSchema {
|
|
|
23
30
|
* @example - number().equalTo(42); // Infers the type 42
|
|
24
31
|
*/
|
|
25
32
|
equalTo(expectedValue) {
|
|
33
|
+
if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
|
|
34
|
+
this.limit = true;
|
|
26
35
|
_setStrictType(this, expectedValue);
|
|
27
36
|
return this.custom(equalTo(expectedValue));
|
|
28
37
|
}
|
|
@@ -36,6 +45,8 @@ var NumberSchema = class extends CommonSchema {
|
|
|
36
45
|
* number().oneOfValues([5, 7]); // Infers the type 5 | 7
|
|
37
46
|
*/
|
|
38
47
|
oneOfValues(expectedValue) {
|
|
48
|
+
if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
|
|
49
|
+
this.limit = true;
|
|
39
50
|
_setStrictType(this, expectedValue);
|
|
40
51
|
return this.custom(oneOfValues(expectedValue));
|
|
41
52
|
}
|
|
@@ -44,4 +55,4 @@ var NumberSchema = class extends CommonSchema {
|
|
|
44
55
|
export {
|
|
45
56
|
NumberSchema
|
|
46
57
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-P7IXNCJG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/NumberSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NumberSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P7IXNCJG.mjs";
|
|
4
4
|
|
|
5
5
|
// src/asserts/number/index.ts
|
|
6
6
|
function number() {
|
|
@@ -10,4 +10,4 @@ function number() {
|
|
|
10
10
|
export {
|
|
11
11
|
number
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-PXBAS3GA.mjs.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKQKJASVBjs = require('./chunk-KQKJASVB.js');
|
|
4
4
|
|
|
5
5
|
// src/asserts/number/index.ts
|
|
6
6
|
function number() {
|
|
7
|
-
return new (0,
|
|
7
|
+
return new (0, _chunkKQKJASVBjs.NumberSchema)({ type: ["number"], requiredValidations: [] });
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
exports.number = number;
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-RD6TBCPQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-RD6TBCPQ.js","../src/asserts/number/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-RD6TBCPQ.js","sourcesContent":[null,"import { NumberSchema } from '../../schemas/NumberSchema';\n\n/**\n * Creates a new schema for validating number values.\n *\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n *\n * @example\n * const schema = number();\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(schema, '42'); // Throws a validation error\n */\nexport function number(): NumberSchema {\n return new NumberSchema({ type: ['number'], requiredValidations: [] });\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkLEQCDD66js = require('./chunk-LEQCDD66.js');
|
|
4
4
|
|
|
5
5
|
// src/asserts/string/index.ts
|
|
6
6
|
function string() {
|
|
7
|
-
return new (0,
|
|
7
|
+
return new (0, _chunkLEQCDD66js.StringSchema)({ type: ["string"], requiredValidations: [] });
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
exports.string = string;
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-TKZ6FLLR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-TKZ6FLLR.js","../src/asserts/string/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-TKZ6FLLR.js","sourcesContent":[null,"import { StringSchema } from '../../schemas/StringSchema';\n\n/**\n * Creates a new schema for validating string values.\n *\n * @returns {StringSchema} A new instance of `StringSchema` for validating strings.\n *\n * @example\n * const schema = string();\n * parseOrFail(schema, 'hello'); // Validates successfully\n * parseOrFail(schema, 123); // Throws a validation error\n */\nexport function string(): StringSchema {\n return new StringSchema({ type: ['string'], requiredValidations: [] });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/helpers/constants.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B;AACE;AACF,+CAAC","file":"/home/runner/work/bguard/bguard/lib/helpers/constants.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTKZ6FLLRjs = require('./chunk-TKZ6FLLR.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkVHEA4JZ5js = require('./chunk-VHEA4JZ5.js');
|
|
7
|
+
require('./chunk-LEQCDD66.js');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
var _chunkIEUXIOL6js = require('./chunk-IEUXIOL6.js');
|
|
@@ -15,15 +16,15 @@ var _chunkHDSGCAHHjs = require('./chunk-HDSGCAHH.js');
|
|
|
15
16
|
var _chunkQQNQ4IDNjs = require('./chunk-QQNQ4IDN.js');
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
var
|
|
19
|
+
var _chunkRD6TBCPQjs = require('./chunk-RD6TBCPQ.js');
|
|
19
20
|
require('./chunk-RRQOET3X.js');
|
|
20
21
|
require('./chunk-WBERBAL4.js');
|
|
21
|
-
require('./chunk-
|
|
22
|
-
require('./chunk-6TH3DBDK.js');
|
|
23
|
-
require('./chunk-F5MSBL33.js');
|
|
22
|
+
require('./chunk-KQKJASVB.js');
|
|
24
23
|
require('./chunk-J4VKFJQK.js');
|
|
25
24
|
require('./chunk-4CYIMDP2.js');
|
|
25
|
+
require('./chunk-42J6CHIO.js');
|
|
26
26
|
require('./chunk-JSGZ7DKT.js');
|
|
27
|
+
require('./chunk-6TH3DBDK.js');
|
|
27
28
|
require('./chunk-EGEHSELT.js');
|
|
28
29
|
|
|
29
30
|
|
|
@@ -57,5 +58,5 @@ var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
|
57
58
|
|
|
58
59
|
|
|
59
60
|
|
|
60
|
-
exports.BuildSchemaError = _chunkWK4O3HH4js.BuildSchemaError; exports.ValidationError = _chunkWK4O3HH4js.ValidationError; exports.array = _chunkIEUXIOL6js.array; exports.boolean = _chunkHDSGCAHHjs.boolean; exports.clearLocales = _chunk5BVJ6YMHjs.clearLocales; exports.guardException = _chunkWK4O3HH4js.guardException; exports.number =
|
|
61
|
+
exports.BuildSchemaError = _chunkWK4O3HH4js.BuildSchemaError; exports.ValidationError = _chunkWK4O3HH4js.ValidationError; exports.array = _chunkIEUXIOL6js.array; exports.boolean = _chunkHDSGCAHHjs.boolean; exports.clearLocales = _chunk5BVJ6YMHjs.clearLocales; exports.guardException = _chunkWK4O3HH4js.guardException; exports.number = _chunkRD6TBCPQjs.number; exports.object = _chunkVHEA4JZ5js.object; exports.oneOfTypes = _chunkQQNQ4IDNjs.oneOfTypes; exports.parse = _chunkH7CPKW53js.parse; exports.parseOrFail = _chunkDJSLA2ZVjs.parseOrFail; exports.setLocale = _chunk5BVJ6YMHjs.setLocale; exports.setToDefaultLocale = _chunk5BVJ6YMHjs.setToDefaultLocale; exports.string = _chunkTKZ6FLLRjs.string;
|
|
61
62
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2rBAAC","file":"/home/runner/work/bguard/bguard/lib/index.js"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2rBAAC","file":"/home/runner/work/bguard/bguard/lib/index.js"}
|
package/lib/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
string
|
|
3
|
+
} from "./chunk-32RSTOZ4.mjs";
|
|
1
4
|
import {
|
|
2
5
|
object
|
|
3
6
|
} from "./chunk-2PM3K3OE.mjs";
|
|
4
|
-
import
|
|
5
|
-
string
|
|
6
|
-
} from "./chunk-NTC2XQ36.mjs";
|
|
7
|
+
import "./chunk-JPRCULRQ.mjs";
|
|
7
8
|
import {
|
|
8
9
|
array
|
|
9
10
|
} from "./chunk-JDGZCBXF.mjs";
|
|
@@ -15,15 +16,15 @@ import {
|
|
|
15
16
|
} from "./chunk-MRISXZQ4.mjs";
|
|
16
17
|
import {
|
|
17
18
|
number
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-PXBAS3GA.mjs";
|
|
19
20
|
import "./chunk-NDQM5OL4.mjs";
|
|
20
21
|
import "./chunk-CCBCDJXS.mjs";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-TCQY2R3U.mjs";
|
|
23
|
-
import "./chunk-FTLRX2XG.mjs";
|
|
22
|
+
import "./chunk-P7IXNCJG.mjs";
|
|
24
23
|
import "./chunk-NNFYXHLU.mjs";
|
|
25
24
|
import "./chunk-3O4WCRC2.mjs";
|
|
25
|
+
import "./chunk-ASZW6XRM.mjs";
|
|
26
26
|
import "./chunk-RYVUYVEE.mjs";
|
|
27
|
+
import "./chunk-TCQY2R3U.mjs";
|
|
27
28
|
import "./chunk-DPBE7TAQ.mjs";
|
|
28
29
|
import {
|
|
29
30
|
parse
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKQKJASVBjs = require('../chunk-KQKJASVB.js');
|
|
4
4
|
require('../chunk-J4VKFJQK.js');
|
|
5
5
|
require('../chunk-4CYIMDP2.js');
|
|
6
|
+
require('../chunk-42J6CHIO.js');
|
|
6
7
|
require('../chunk-JSGZ7DKT.js');
|
|
7
8
|
require('../chunk-EGEHSELT.js');
|
|
8
9
|
require('../chunk-IRG4OQAB.js');
|
|
@@ -10,5 +11,5 @@ require('../chunk-5BVJ6YMH.js');
|
|
|
10
11
|
require('../chunk-WK4O3HH4.js');
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
exports.NumberSchema =
|
|
14
|
+
exports.NumberSchema = _chunkKQKJASVBjs.NumberSchema;
|
|
14
15
|
//# sourceMappingURL=NumberSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/schemas/NumberSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/schemas/NumberSchema.js"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/schemas/NumberSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/schemas/NumberSchema.js"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NumberSchema
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-P7IXNCJG.mjs";
|
|
4
4
|
import "../chunk-NNFYXHLU.mjs";
|
|
5
5
|
import "../chunk-3O4WCRC2.mjs";
|
|
6
|
+
import "../chunk-ASZW6XRM.mjs";
|
|
6
7
|
import "../chunk-RYVUYVEE.mjs";
|
|
7
8
|
import "../chunk-DPBE7TAQ.mjs";
|
|
8
9
|
import "../chunk-PH2PMUZP.mjs";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkLEQCDD66js = require('../chunk-LEQCDD66.js');
|
|
4
4
|
require('../chunk-J4VKFJQK.js');
|
|
5
5
|
require('../chunk-4CYIMDP2.js');
|
|
6
|
+
require('../chunk-42J6CHIO.js');
|
|
6
7
|
require('../chunk-JSGZ7DKT.js');
|
|
7
8
|
require('../chunk-EGEHSELT.js');
|
|
8
9
|
require('../chunk-IRG4OQAB.js');
|
|
@@ -10,5 +11,5 @@ require('../chunk-5BVJ6YMH.js');
|
|
|
10
11
|
require('../chunk-WK4O3HH4.js');
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
exports.StringSchema =
|
|
14
|
+
exports.StringSchema = _chunkLEQCDD66js.StringSchema;
|
|
14
15
|
//# sourceMappingURL=StringSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/schemas/StringSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/schemas/StringSchema.js"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/schemas/StringSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,qDAAC","file":"/home/runner/work/bguard/bguard/lib/schemas/StringSchema.js"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StringSchema
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-JPRCULRQ.mjs";
|
|
4
4
|
import "../chunk-NNFYXHLU.mjs";
|
|
5
5
|
import "../chunk-3O4WCRC2.mjs";
|
|
6
|
+
import "../chunk-ASZW6XRM.mjs";
|
|
6
7
|
import "../chunk-RYVUYVEE.mjs";
|
|
7
8
|
import "../chunk-DPBE7TAQ.mjs";
|
|
8
9
|
import "../chunk-PH2PMUZP.mjs";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/NumberSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;AAKO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,QAA0B,eAAuC;AAC/D,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-F5MSBL33.js","../src/schemas/StringSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACRO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,6CAAA,IAAe,EAAM,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,CAAG,CAAA;AACzC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,6CAAA;AAAA,MACE,IAAA;AAAA,MACA,aAAA,CAAc,GAAA,CAAI,CAAC,EAAA,EAAA,GAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG;AAAA,IACrC,CAAA;AACA,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADQA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-F5MSBL33.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n _setStrictType(this, `'${expectedValue}'`);\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n _setStrictType(this, `'${expectedValue}'`);\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;AAKO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,QAA0B,eAAuC;AAC/D,mBAAe,MAAM,IAAI,aAAa,GAAG;AACzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-RQH4LXBW.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACRO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADQA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-RQH4LXBW.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"]}
|
|
File without changes
|
|
File without changes
|