umt 2.19.0 → 2.20.0
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/module/Validate/any/core.d.ts +21 -0
- package/module/Validate/any/core.js +19 -0
- package/module/Validate/any/core.js.map +1 -0
- package/module/Validate/any/index.d.ts +1 -0
- package/module/Validate/any/index.js +2 -0
- package/module/Validate/any/index.js.map +1 -0
- package/module/Validate/array/arrayOf.d.ts +6 -1
- package/module/Validate/array/arrayOf.js +1 -0
- package/module/Validate/array/arrayOf.js.map +1 -1
- package/module/Validate/bigint/core.d.ts +24 -0
- package/module/Validate/bigint/core.js +37 -0
- package/module/Validate/bigint/core.js.map +1 -0
- package/module/Validate/bigint/index.d.ts +1 -0
- package/module/Validate/bigint/index.js +2 -0
- package/module/Validate/bigint/index.js.map +1 -0
- package/module/Validate/date/core.d.ts +14 -0
- package/module/Validate/date/core.js +29 -0
- package/module/Validate/date/core.js.map +1 -0
- package/module/Validate/date/index.d.ts +1 -0
- package/module/Validate/date/index.js +2 -0
- package/module/Validate/date/index.js.map +1 -0
- package/module/Validate/file/core.d.ts +13 -0
- package/module/Validate/file/core.js +32 -0
- package/module/Validate/file/core.js.map +1 -0
- package/module/Validate/file/index.d.ts +1 -0
- package/module/Validate/file/index.js +2 -0
- package/module/Validate/file/index.js.map +1 -0
- package/module/Validate/function/core.d.ts +75 -0
- package/module/Validate/function/core.js +66 -0
- package/module/Validate/function/core.js.map +1 -0
- package/module/Validate/function/index.d.ts +1 -0
- package/module/Validate/function/index.js +2 -0
- package/module/Validate/function/index.js.map +1 -0
- package/module/Validate/index.d.ts +11 -0
- package/module/Validate/index.js +11 -0
- package/module/Validate/index.js.map +1 -1
- package/module/Validate/instanceof/core.d.ts +19 -0
- package/module/Validate/instanceof/core.js +32 -0
- package/module/Validate/instanceof/core.js.map +1 -0
- package/module/Validate/instanceof/index.d.ts +1 -0
- package/module/Validate/instanceof/index.js +2 -0
- package/module/Validate/instanceof/index.js.map +1 -0
- package/module/Validate/map/core.d.ts +24 -0
- package/module/Validate/map/core.js +57 -0
- package/module/Validate/map/core.js.map +1 -0
- package/module/Validate/map/index.d.ts +1 -0
- package/module/Validate/map/index.js +2 -0
- package/module/Validate/map/index.js.map +1 -0
- package/module/Validate/never/core.d.ts +22 -0
- package/module/Validate/never/core.js +23 -0
- package/module/Validate/never/core.js.map +1 -0
- package/module/Validate/never/index.d.ts +1 -0
- package/module/Validate/never/index.js +2 -0
- package/module/Validate/never/index.js.map +1 -0
- package/module/Validate/object/core.d.ts +22 -4
- package/module/Validate/object/core.js +5 -3
- package/module/Validate/object/core.js.map +1 -1
- package/module/Validate/object/index.d.ts +4 -0
- package/module/Validate/object/index.js +4 -0
- package/module/Validate/object/index.js.map +1 -1
- package/module/Validate/object/nullable.d.ts +12 -2
- package/module/Validate/object/nullable.js +2 -2
- package/module/Validate/object/nullable.js.map +1 -1
- package/module/Validate/object/omit.d.ts +22 -0
- package/module/Validate/object/omit.js +33 -0
- package/module/Validate/object/omit.js.map +1 -0
- package/module/Validate/object/optional.d.ts +31 -3
- package/module/Validate/object/optional.js +7 -5
- package/module/Validate/object/optional.js.map +1 -1
- package/module/Validate/object/partial.d.ts +25 -0
- package/module/Validate/object/partial.js +29 -0
- package/module/Validate/object/partial.js.map +1 -0
- package/module/Validate/object/pick.d.ts +21 -0
- package/module/Validate/object/pick.js +29 -0
- package/module/Validate/object/pick.js.map +1 -0
- package/module/Validate/object/required.d.ts +22 -0
- package/module/Validate/object/required.js +30 -0
- package/module/Validate/object/required.js.map +1 -0
- package/module/Validate/set/core.d.ts +24 -0
- package/module/Validate/set/core.js +47 -0
- package/module/Validate/set/core.js.map +1 -0
- package/module/Validate/set/index.d.ts +1 -0
- package/module/Validate/set/index.js +2 -0
- package/module/Validate/set/index.js.map +1 -0
- package/module/Validate/templateLiteral/core.d.ts +55 -0
- package/module/Validate/templateLiteral/core.js +68 -0
- package/module/Validate/templateLiteral/core.js.map +1 -0
- package/module/Validate/templateLiteral/index.d.ts +1 -0
- package/module/Validate/templateLiteral/index.js +2 -0
- package/module/Validate/templateLiteral/index.js.map +1 -0
- package/module/Validate/type.d.ts +7 -5
- package/module/Validate/unknown/core.d.ts +21 -0
- package/module/Validate/unknown/core.js +16 -0
- package/module/Validate/unknown/core.js.map +1 -0
- package/module/Validate/unknown/index.d.ts +1 -0
- package/module/Validate/unknown/index.js +2 -0
- package/module/Validate/unknown/index.js.map +1 -0
- package/module/es5/Validate/any/core.d.ts +21 -0
- package/module/es5/Validate/any/core.js +36 -0
- package/module/es5/Validate/any/index.d.ts +1 -0
- package/module/es5/Validate/any/index.js +16 -0
- package/module/es5/Validate/array/arrayOf.d.ts +6 -1
- package/module/es5/Validate/array/arrayOf.js +1 -0
- package/module/es5/Validate/bigint/core.d.ts +24 -0
- package/module/es5/Validate/bigint/core.js +65 -0
- package/module/es5/Validate/bigint/index.d.ts +1 -0
- package/module/es5/Validate/bigint/index.js +16 -0
- package/module/es5/Validate/date/core.d.ts +14 -0
- package/module/es5/Validate/date/core.js +35 -0
- package/module/es5/Validate/date/index.d.ts +1 -0
- package/module/es5/Validate/date/index.js +16 -0
- package/module/es5/Validate/file/core.d.ts +13 -0
- package/module/es5/Validate/file/core.js +39 -0
- package/module/es5/Validate/file/index.d.ts +1 -0
- package/module/es5/Validate/file/index.js +16 -0
- package/module/es5/Validate/function/core.d.ts +75 -0
- package/module/es5/Validate/function/core.js +125 -0
- package/module/es5/Validate/function/index.d.ts +1 -0
- package/module/es5/Validate/function/index.js +16 -0
- package/module/es5/Validate/index.d.ts +11 -0
- package/module/es5/Validate/index.js +121 -0
- package/module/es5/Validate/instanceof/core.d.ts +19 -0
- package/module/es5/Validate/instanceof/core.js +40 -0
- package/module/es5/Validate/instanceof/index.d.ts +1 -0
- package/module/es5/Validate/instanceof/index.js +16 -0
- package/module/es5/Validate/map/core.d.ts +24 -0
- package/module/es5/Validate/map/core.js +81 -0
- package/module/es5/Validate/map/index.d.ts +1 -0
- package/module/es5/Validate/map/index.js +16 -0
- package/module/es5/Validate/never/core.d.ts +22 -0
- package/module/es5/Validate/never/core.js +35 -0
- package/module/es5/Validate/never/index.d.ts +1 -0
- package/module/es5/Validate/never/index.js +16 -0
- package/module/es5/Validate/object/core.d.ts +22 -4
- package/module/es5/Validate/object/core.js +14 -2
- package/module/es5/Validate/object/index.d.ts +4 -0
- package/module/es5/Validate/object/index.js +44 -0
- package/module/es5/Validate/object/nullable.d.ts +12 -2
- package/module/es5/Validate/object/nullable.js +2 -2
- package/module/es5/Validate/object/omit.d.ts +22 -0
- package/module/es5/Validate/object/omit.js +39 -0
- package/module/es5/Validate/object/optional.d.ts +31 -3
- package/module/es5/Validate/object/optional.js +12 -3
- package/module/es5/Validate/object/partial.d.ts +25 -0
- package/module/es5/Validate/object/partial.js +33 -0
- package/module/es5/Validate/object/pick.d.ts +21 -0
- package/module/es5/Validate/object/pick.js +45 -0
- package/module/es5/Validate/object/required.d.ts +22 -0
- package/module/es5/Validate/object/required.js +33 -0
- package/module/es5/Validate/set/core.d.ts +24 -0
- package/module/es5/Validate/set/core.js +65 -0
- package/module/es5/Validate/set/index.d.ts +1 -0
- package/module/es5/Validate/set/index.js +16 -0
- package/module/es5/Validate/templateLiteral/core.d.ts +55 -0
- package/module/es5/Validate/templateLiteral/core.js +114 -0
- package/module/es5/Validate/templateLiteral/index.d.ts +1 -0
- package/module/es5/Validate/templateLiteral/index.js +16 -0
- package/module/es5/Validate/type.d.ts +7 -5
- package/module/es5/Validate/unknown/core.d.ts +21 -0
- package/module/es5/Validate/unknown/core.js +34 -0
- package/module/es5/Validate/unknown/index.d.ts +1 -0
- package/module/es5/Validate/unknown/index.js +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Any validation core module
|
|
3
|
+
* Provides a validator that accepts any value, useful when a position in a
|
|
4
|
+
* schema needs to remain wide open while still participating in `object()`,
|
|
5
|
+
* `union()`, `intersection()`, and other compositional helpers.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Return type produced by an `any` validator. Exposes the literal `"any"`
|
|
9
|
+
* tag through the `type` field so `ValidateType<"any">` can map it back to
|
|
10
|
+
* the `any` runtime type when consumed by downstream helpers.
|
|
11
|
+
*/
|
|
12
|
+
export interface AnyReturnType {
|
|
13
|
+
validate: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
type: "any";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a validator that accepts any value
|
|
19
|
+
* @returns {Function} - Validator that always succeeds
|
|
20
|
+
*/
|
|
21
|
+
export declare const any: () => ((value: any) => AnyReturnType);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Any validation core module
|
|
3
|
+
* Provides a validator that accepts any value, useful when a position in a
|
|
4
|
+
* schema needs to remain wide open while still participating in `object()`,
|
|
5
|
+
* `union()`, `intersection()`, and other compositional helpers.
|
|
6
|
+
*/
|
|
7
|
+
// biome-ignore lint/suspicious/noExplicitAny: signature mirrors the return type
|
|
8
|
+
const anyValidator = (_value) => ({
|
|
9
|
+
validate: true,
|
|
10
|
+
message: "",
|
|
11
|
+
type: "any",
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Creates a validator that accepts any value
|
|
15
|
+
* @returns {Function} - Validator that always succeeds
|
|
16
|
+
*/
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: any() must accept and infer any value
|
|
18
|
+
export const any = () => anyValidator;
|
|
19
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/any/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,gFAAgF;AAChF,MAAM,YAAY,GAAG,CAAC,MAAW,EAAiB,EAAE,CAAC,CAAC;IACpD,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,KAAK;CACZ,CAAC,CAAC;AAEH;;;GAGG;AACH,oFAAoF;AACpF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAoC,EAAE,CAAC,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/any/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -2,8 +2,13 @@ import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates an array validator that validates every element with a single validator
|
|
4
4
|
* @template T - Element type validated by the wrapped validator
|
|
5
|
+
* @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
|
|
5
6
|
* @param {Function} validator - Validator applied to each element (e.g. an object validator)
|
|
6
7
|
* @param {string} [message] - Custom error message for array type validation
|
|
7
8
|
* @returns {Function} - Validator function for arrays whose elements satisfy the given validator
|
|
8
9
|
*/
|
|
9
|
-
export declare const arrayOf: <T
|
|
10
|
+
export declare const arrayOf: <T, R extends {
|
|
11
|
+
type: unknown;
|
|
12
|
+
message: string;
|
|
13
|
+
validate: boolean;
|
|
14
|
+
}>(validator: (value: T) => R, message?: string) => (values: T[]) => ValidateCoreReturnType<T[]>;
|
|
@@ -2,6 +2,7 @@ import { isArray } from "../../Validate/isArray";
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates an array validator that validates every element with a single validator
|
|
4
4
|
* @template T - Element type validated by the wrapped validator
|
|
5
|
+
* @template R - The return type of the wrapped validator (preserved so the inner type tag flows through)
|
|
5
6
|
* @param {Function} validator - Validator applied to each element (e.g. an object validator)
|
|
6
7
|
* @param {string} [message] - Custom error message for array type validation
|
|
7
8
|
* @returns {Function} - Validator function for arrays whose elements satisfy the given validator
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrayOf.js","sourceRoot":"","sources":["../../../src/Validate/array/arrayOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C
|
|
1
|
+
{"version":3,"file":"arrayOf.js","sourceRoot":"","sources":["../../../src/Validate/array/arrayOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAIrB,SAA0B,EAC1B,OAAgB,EAChB,EAAE;IACF,OAAO,CAAC,MAAW,EAA+B,EAAE;QAClD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,MAAM;aACb,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrB,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,IAAI,EAAE,MAAM;iBACb,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,MAAM;SACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BigInt validation core module
|
|
3
|
+
* Provides the base validation functionality for bigint values
|
|
4
|
+
*/
|
|
5
|
+
import type { ValidateReturnType } from "../../Validate/type";
|
|
6
|
+
/**
|
|
7
|
+
* Return type produced by a `bigint` validator. Structurally compatible with
|
|
8
|
+
* `ValidateCoreReturnType<bigint>`, but exposes the literal `"bigint"` tag
|
|
9
|
+
* through the `type` field so `ValidateType<"bigint">` can map it back to the
|
|
10
|
+
* `bigint` runtime type when consumed by `object()`, `union()`, and friends.
|
|
11
|
+
*/
|
|
12
|
+
export interface BigIntReturnType {
|
|
13
|
+
validate: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
type: "bigint";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a bigint validator with optional validation rules
|
|
19
|
+
* @template T - Array of validation rules for bigints
|
|
20
|
+
* @param {T} [option] - Array of validation functions to apply
|
|
21
|
+
* @param {string} [message] - Custom error message for type validation
|
|
22
|
+
* @returns {Function} - Validator function that checks if the value is a bigint and applies validation rules
|
|
23
|
+
*/
|
|
24
|
+
export declare const bigint: <T extends ValidateReturnType<bigint>[]>(option?: T, message?: string) => (value: bigint) => BigIntReturnType;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BigInt validation core module
|
|
3
|
+
* Provides the base validation functionality for bigint values
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Creates a bigint validator with optional validation rules
|
|
7
|
+
* @template T - Array of validation rules for bigints
|
|
8
|
+
* @param {T} [option] - Array of validation functions to apply
|
|
9
|
+
* @param {string} [message] - Custom error message for type validation
|
|
10
|
+
* @returns {Function} - Validator function that checks if the value is a bigint and applies validation rules
|
|
11
|
+
*/
|
|
12
|
+
export const bigint = (option = [], message) => {
|
|
13
|
+
return (value) => {
|
|
14
|
+
if (typeof value !== "bigint") {
|
|
15
|
+
return {
|
|
16
|
+
validate: false,
|
|
17
|
+
message: message ?? "",
|
|
18
|
+
type: "bigint",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
for (const rule of option) {
|
|
22
|
+
if (!rule.validate(value)) {
|
|
23
|
+
return {
|
|
24
|
+
validate: false,
|
|
25
|
+
message: rule.message ?? "",
|
|
26
|
+
type: "bigint",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
validate: true,
|
|
32
|
+
message: "",
|
|
33
|
+
type: "bigint",
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/bigint/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,SAAY,EAAkB,EAC9B,OAAgB,EAChB,EAAE;IACF,OAAO,CAAC,KAAa,EAAoB,EAAE;QACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,QAAQ;aACf,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;oBAC3B,IAAI,EAAE,QAAQ;iBACf,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/bigint/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date validation core module
|
|
3
|
+
* Provides the base validation functionality for Date instances
|
|
4
|
+
*/
|
|
5
|
+
import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Date validator. The validator checks both that the value is an
|
|
8
|
+
* instance of Date and that it represents a valid moment in time (i.e. its
|
|
9
|
+
* underlying timestamp is not NaN), so values created from invalid inputs
|
|
10
|
+
* such as `new Date("not-a-date")` are rejected.
|
|
11
|
+
* @param {string} [message] - Custom error message for type validation
|
|
12
|
+
* @returns {Function} - Validator function that checks if the value is a Date instance
|
|
13
|
+
*/
|
|
14
|
+
export declare const date: (message?: string) => (value: Date) => ValidateCoreReturnType<Date>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date validation core module
|
|
3
|
+
* Provides the base validation functionality for Date instances
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Date validator. The validator checks both that the value is an
|
|
7
|
+
* instance of Date and that it represents a valid moment in time (i.e. its
|
|
8
|
+
* underlying timestamp is not NaN), so values created from invalid inputs
|
|
9
|
+
* such as `new Date("not-a-date")` are rejected.
|
|
10
|
+
* @param {string} [message] - Custom error message for type validation
|
|
11
|
+
* @returns {Function} - Validator function that checks if the value is a Date instance
|
|
12
|
+
*/
|
|
13
|
+
export const date = (message) => {
|
|
14
|
+
return (value) => {
|
|
15
|
+
if (!(value instanceof Date) || Number.isNaN(value.getTime())) {
|
|
16
|
+
return {
|
|
17
|
+
validate: false,
|
|
18
|
+
message: message ?? "",
|
|
19
|
+
type: value,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
validate: true,
|
|
24
|
+
message: "",
|
|
25
|
+
type: value,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/date/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAgB,EAAE,EAAE;IACvC,OAAO,CAAC,KAAW,EAAgC,EAAE;QACnD,IAAI,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YAC9D,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/date/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File validation core module
|
|
3
|
+
* Provides validation for File / Blob instances. Falls back to `Blob` when
|
|
4
|
+
* the global `File` constructor is unavailable.
|
|
5
|
+
*/
|
|
6
|
+
import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
7
|
+
/**
|
|
8
|
+
* Creates a validator that checks whether a value is a `File` (or `Blob` in
|
|
9
|
+
* runtimes where `File` is not available)
|
|
10
|
+
* @param {string} [message] - Custom error message for type validation
|
|
11
|
+
* @returns {Function} - Validator function for File / Blob instances
|
|
12
|
+
*/
|
|
13
|
+
export declare const file: (message?: string) => (value: File) => ValidateCoreReturnType<File>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File validation core module
|
|
3
|
+
* Provides validation for File / Blob instances. Falls back to `Blob` when
|
|
4
|
+
* the global `File` constructor is unavailable.
|
|
5
|
+
*/
|
|
6
|
+
const hasFileConstructor = typeof File !== "undefined";
|
|
7
|
+
const hasBlobConstructor = typeof Blob !== "undefined";
|
|
8
|
+
/**
|
|
9
|
+
* Creates a validator that checks whether a value is a `File` (or `Blob` in
|
|
10
|
+
* runtimes where `File` is not available)
|
|
11
|
+
* @param {string} [message] - Custom error message for type validation
|
|
12
|
+
* @returns {Function} - Validator function for File / Blob instances
|
|
13
|
+
*/
|
|
14
|
+
export const file = (message) => {
|
|
15
|
+
return (value) => {
|
|
16
|
+
const isFile = hasFileConstructor && value instanceof File;
|
|
17
|
+
const isBlob = hasBlobConstructor && value instanceof Blob;
|
|
18
|
+
if (!(isFile || isBlob)) {
|
|
19
|
+
return {
|
|
20
|
+
validate: false,
|
|
21
|
+
message: message ?? "",
|
|
22
|
+
type: value,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
validate: true,
|
|
27
|
+
message: "",
|
|
28
|
+
type: value,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/file/core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,kBAAkB,GAAG,OAAO,IAAI,KAAK,WAAW,CAAC;AACvD,MAAM,kBAAkB,GAAG,OAAO,IAAI,KAAK,WAAW,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAgB,EAAE,EAAE;IACvC,OAAO,CAAC,KAAW,EAAgC,EAAE;QACnD,MAAM,MAAM,GAAG,kBAAkB,IAAI,KAAK,YAAY,IAAI,CAAC;QAC3D,MAAM,MAAM,GAAG,kBAAkB,IAAI,KAAK,YAAY,IAAI,CAAC;QAC3D,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,EAAE,CAAC;YACxB,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/file/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function validation core module
|
|
3
|
+
* Provides a validator for function values along with an `implement()`
|
|
4
|
+
* helper that wraps a concrete function with runtime validation of its
|
|
5
|
+
* inputs and output.
|
|
6
|
+
*
|
|
7
|
+
* The runtime validator only enforces that the value is a function, since
|
|
8
|
+
* argument and return-value contracts can only be checked when the function
|
|
9
|
+
* is actually invoked. Use `.implement()` (or call the validator's
|
|
10
|
+
* `implement` property directly) to create a wrapped function that asserts
|
|
11
|
+
* the schema on every call.
|
|
12
|
+
*/
|
|
13
|
+
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
14
|
+
type AnyValidator = (value: any) => ValidateCoreReturnType<unknown>;
|
|
15
|
+
type ExtractValidatedType<V> = V extends (value: never) => {
|
|
16
|
+
type: infer T;
|
|
17
|
+
} ? ValidateType<T> : never;
|
|
18
|
+
type InferInputs<Inputs> = Inputs extends readonly AnyValidator[] ? {
|
|
19
|
+
[K in keyof Inputs]: ExtractValidatedType<Inputs[K]>;
|
|
20
|
+
} : any[];
|
|
21
|
+
type InferOutput<Output> = Output extends AnyValidator ? ExtractValidatedType<Output> : any;
|
|
22
|
+
/**
|
|
23
|
+
* Function schema definition. `input` describes positional parameters and
|
|
24
|
+
* `output` describes the return type. Both are optional; when omitted the
|
|
25
|
+
* validator only enforces that the value is callable.
|
|
26
|
+
*/
|
|
27
|
+
export interface FunctionSchema {
|
|
28
|
+
input?: readonly AnyValidator[];
|
|
29
|
+
output?: AnyValidator;
|
|
30
|
+
}
|
|
31
|
+
type ExtractInput<S> = S extends {
|
|
32
|
+
input: infer I;
|
|
33
|
+
} ? I : undefined;
|
|
34
|
+
type ExtractOutput<S> = S extends {
|
|
35
|
+
output: infer O;
|
|
36
|
+
} ? O : undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Inferred function signature from a `FunctionSchema`. Used by callers via
|
|
39
|
+
* `SchemaToInterface` and as the return type of `implement()`.
|
|
40
|
+
* @template Inputs - Tuple of validators describing positional parameters
|
|
41
|
+
* @template Output - Validator describing the return value
|
|
42
|
+
*/
|
|
43
|
+
export type InferFunction<Inputs, Output> = (...arguments_: InferInputs<Inputs>) => InferOutput<Output>;
|
|
44
|
+
/**
|
|
45
|
+
* Validator return type. Carries the inferred function signature through
|
|
46
|
+
* the `type` field so `SchemaToInterface` can recover it.
|
|
47
|
+
* @template Inputs - Tuple of validators describing positional parameters
|
|
48
|
+
* @template Output - Validator describing the return value
|
|
49
|
+
*/
|
|
50
|
+
export interface FunctionReturnType<Inputs, Output> {
|
|
51
|
+
validate: boolean;
|
|
52
|
+
message: string;
|
|
53
|
+
type: InferFunction<Inputs, Output>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Validator value enriched with an `implement()` method that returns a
|
|
57
|
+
* runtime-checked wrapper of a concrete function matching the schema.
|
|
58
|
+
* @template Inputs - Tuple of validators describing positional parameters
|
|
59
|
+
* @template Output - Validator describing the return value
|
|
60
|
+
*/
|
|
61
|
+
export interface FunctionValidator<Inputs, Output> {
|
|
62
|
+
(value: InferFunction<Inputs, Output>): FunctionReturnType<Inputs, Output>;
|
|
63
|
+
implement: (function__: InferFunction<Inputs, Output>) => InferFunction<Inputs, Output>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a function validator. When invoked the validator only checks that
|
|
67
|
+
* the value is callable; use `.implement()` on the returned validator to
|
|
68
|
+
* obtain a runtime-checked wrapper that asserts the schema for each call.
|
|
69
|
+
* @template S - Function schema type, captured for input/output inference
|
|
70
|
+
* @param {S} [schema] - Function schema definition
|
|
71
|
+
* @param {string} [message] - Custom error message for type validation
|
|
72
|
+
* @returns {FunctionValidator} - Validator augmented with `implement()`
|
|
73
|
+
*/
|
|
74
|
+
export declare const function_: <const S extends FunctionSchema = FunctionSchema>(schema?: S, message?: string) => FunctionValidator<ExtractInput<S>, ExtractOutput<S>>;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function validation core module
|
|
3
|
+
* Provides a validator for function values along with an `implement()`
|
|
4
|
+
* helper that wraps a concrete function with runtime validation of its
|
|
5
|
+
* inputs and output.
|
|
6
|
+
*
|
|
7
|
+
* The runtime validator only enforces that the value is a function, since
|
|
8
|
+
* argument and return-value contracts can only be checked when the function
|
|
9
|
+
* is actually invoked. Use `.implement()` (or call the validator's
|
|
10
|
+
* `implement` property directly) to create a wrapped function that asserts
|
|
11
|
+
* the schema on every call.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Creates a function validator. When invoked the validator only checks that
|
|
15
|
+
* the value is callable; use `.implement()` on the returned validator to
|
|
16
|
+
* obtain a runtime-checked wrapper that asserts the schema for each call.
|
|
17
|
+
* @template S - Function schema type, captured for input/output inference
|
|
18
|
+
* @param {S} [schema] - Function schema definition
|
|
19
|
+
* @param {string} [message] - Custom error message for type validation
|
|
20
|
+
* @returns {FunctionValidator} - Validator augmented with `implement()`
|
|
21
|
+
*/
|
|
22
|
+
export const function_ = (schema, message) => {
|
|
23
|
+
const inputs = schema?.input;
|
|
24
|
+
const output = schema?.output;
|
|
25
|
+
const validator = ((value) => {
|
|
26
|
+
if (typeof value !== "function") {
|
|
27
|
+
return {
|
|
28
|
+
validate: false,
|
|
29
|
+
message: message ?? "",
|
|
30
|
+
type: value,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
validate: true,
|
|
35
|
+
message: "",
|
|
36
|
+
type: value,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
validator.implement = (function__) => {
|
|
40
|
+
if (typeof function__ !== "function") {
|
|
41
|
+
throw new TypeError(message ?? "value is not a function");
|
|
42
|
+
}
|
|
43
|
+
const wrapped = (...arguments_) => {
|
|
44
|
+
if (inputs) {
|
|
45
|
+
for (const [index, inputValidator] of inputs.entries()) {
|
|
46
|
+
const result = inputValidator(arguments_[index]);
|
|
47
|
+
if (!result.validate) {
|
|
48
|
+
throw new TypeError(result.message ||
|
|
49
|
+
`function input at index ${index} failed validation`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const returnValue = function__(...arguments_);
|
|
54
|
+
if (output) {
|
|
55
|
+
const result = output(returnValue);
|
|
56
|
+
if (!result.validate) {
|
|
57
|
+
throw new TypeError(result.message || "function output failed validation");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return returnValue;
|
|
61
|
+
};
|
|
62
|
+
return wrapped;
|
|
63
|
+
};
|
|
64
|
+
return validator;
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/function/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAU,EACV,OAAgB,EACsC,EAAE;IAGxD,MAAM,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,CAAC,KAAoC,EAAE,EAAE;QAC1D,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAsC,CAAC;IAExC,SAAS,CAAC,SAAS,GAAG,CAAC,UAAU,EAAE,EAAE;QACnC,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE,CAAC;YACrC,MAAM,IAAI,SAAS,CAAC,OAAO,IAAI,yBAAyB,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,GAAG,UAA+B,EAAE,EAAE;YACrD,IAAI,MAAM,EAAE,CAAC;gBACX,KAAK,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;oBACvD,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;oBACjD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;wBACrB,MAAM,IAAI,SAAS,CACjB,MAAM,CAAC,OAAO;4BACZ,2BAA2B,KAAK,oBAAoB,CACvD,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM,WAAW,GACf,UACD,CAAC,GAAI,UAAmC,CAAC,CAAC;YAC3C,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;gBACnC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;oBACrB,MAAM,IAAI,SAAS,CACjB,MAAM,CAAC,OAAO,IAAI,mCAAmC,CACtD,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,WAAkC,CAAC;QAC5C,CAAC,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
export * from "./any";
|
|
1
2
|
export * from "./array";
|
|
3
|
+
export * from "./bigint";
|
|
2
4
|
export * from "./boolean";
|
|
5
|
+
export * from "./date";
|
|
6
|
+
export * from "./file";
|
|
7
|
+
export * from "./function";
|
|
8
|
+
export * from "./instanceof";
|
|
9
|
+
export * from "./map";
|
|
10
|
+
export * from "./never";
|
|
3
11
|
export * from "./number";
|
|
4
12
|
export * from "./object";
|
|
13
|
+
export * from "./set";
|
|
5
14
|
export * from "./string";
|
|
15
|
+
export * from "./templateLiteral";
|
|
6
16
|
export * from "./type";
|
|
17
|
+
export * from "./unknown";
|
|
7
18
|
export * from "./isDeepEqual";
|
|
8
19
|
export * from "./isArray";
|
|
9
20
|
export * from "./isBrowser";
|
package/module/Validate/index.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
// Validate Function
|
|
2
|
+
export * from "./any";
|
|
2
3
|
export * from "./array";
|
|
4
|
+
export * from "./bigint";
|
|
3
5
|
export * from "./boolean";
|
|
6
|
+
export * from "./date";
|
|
7
|
+
export * from "./file";
|
|
8
|
+
export * from "./function";
|
|
9
|
+
export * from "./instanceof";
|
|
10
|
+
export * from "./map";
|
|
11
|
+
export * from "./never";
|
|
4
12
|
export * from "./number";
|
|
5
13
|
export * from "./object";
|
|
14
|
+
export * from "./set";
|
|
6
15
|
export * from "./string";
|
|
16
|
+
export * from "./templateLiteral";
|
|
7
17
|
export * from "./type";
|
|
18
|
+
export * from "./unknown";
|
|
8
19
|
// Other Validate
|
|
9
20
|
export * from "./isDeepEqual";
|
|
10
21
|
export * from "./isArray";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Validate/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Validate/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAE1B,iBAAiB;AACjB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* instanceof validation core module
|
|
3
|
+
* Provides a validator that checks whether a value is an instance of a
|
|
4
|
+
* specific constructor, including subclasses. The validator is exported as
|
|
5
|
+
* `instanceof_` because `instanceof` is a reserved keyword in JavaScript.
|
|
6
|
+
*/
|
|
7
|
+
import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
8
|
+
type Constructor<T> = new (...arguments_: any[]) => T;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a validator that checks whether a value is an instance of the given
|
|
11
|
+
* constructor. Subclasses of the constructor satisfy the validator, matching
|
|
12
|
+
* native `instanceof` semantics.
|
|
13
|
+
* @template T - The instance type produced by the constructor
|
|
14
|
+
* @param {Constructor<T>} classConstructor - Constructor whose instances are accepted
|
|
15
|
+
* @param {string} [message] - Custom error message for validation failure
|
|
16
|
+
* @returns {Function} - Validator function for instances of the constructor
|
|
17
|
+
*/
|
|
18
|
+
export declare const instanceof_: <T>(classConstructor: Constructor<T>, message?: string) => (value: T) => ValidateCoreReturnType<T>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* instanceof validation core module
|
|
3
|
+
* Provides a validator that checks whether a value is an instance of a
|
|
4
|
+
* specific constructor, including subclasses. The validator is exported as
|
|
5
|
+
* `instanceof_` because `instanceof` is a reserved keyword in JavaScript.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Creates a validator that checks whether a value is an instance of the given
|
|
9
|
+
* constructor. Subclasses of the constructor satisfy the validator, matching
|
|
10
|
+
* native `instanceof` semantics.
|
|
11
|
+
* @template T - The instance type produced by the constructor
|
|
12
|
+
* @param {Constructor<T>} classConstructor - Constructor whose instances are accepted
|
|
13
|
+
* @param {string} [message] - Custom error message for validation failure
|
|
14
|
+
* @returns {Function} - Validator function for instances of the constructor
|
|
15
|
+
*/
|
|
16
|
+
export const instanceof_ = (classConstructor, message) => {
|
|
17
|
+
return (value) => {
|
|
18
|
+
if (!(value instanceof classConstructor)) {
|
|
19
|
+
return {
|
|
20
|
+
validate: false,
|
|
21
|
+
message: message ?? "",
|
|
22
|
+
type: value,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
validate: true,
|
|
27
|
+
message: "",
|
|
28
|
+
type: value,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/instanceof/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,gBAAgC,EAChC,OAAgB,EAChB,EAAE;IACF,OAAO,CAAC,KAAQ,EAA6B,EAAE;QAC7C,IAAI,CAAC,CAAC,KAAK,YAAY,gBAAgB,CAAC,EAAE,CAAC;YACzC,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAA4B;aACnC,CAAC;QACJ,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAA4B;SACnC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/instanceof/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map validation core module
|
|
3
|
+
* Provides validation for `Map` instances. The validator can optionally
|
|
4
|
+
* delegate to per-entry validators for keys and values, mirroring how
|
|
5
|
+
* `arrayOf()` validates each element of an array.
|
|
6
|
+
*/
|
|
7
|
+
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
8
|
+
type ExtractValidatedType<V> = V extends (value: never) => {
|
|
9
|
+
type: infer T;
|
|
10
|
+
} ? ValidateType<T> : never;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a Map validator. The validator can optionally accept per-entry key
|
|
13
|
+
* and value validators that are applied to every entry of the map. When the
|
|
14
|
+
* value-side validator is provided, the entry validators short-circuit on the
|
|
15
|
+
* first failure and surface the failing message, mirroring `arrayOf()`.
|
|
16
|
+
* @template KV - Validator for the map key
|
|
17
|
+
* @template VV - Validator for the map value
|
|
18
|
+
* @param {KV} [keyValidator] - Validator applied to every key
|
|
19
|
+
* @param {VV} [valueValidator] - Validator applied to every value
|
|
20
|
+
* @param {string} [message] - Custom error message for type validation
|
|
21
|
+
* @returns {Function} - Validator function for Map instances
|
|
22
|
+
*/
|
|
23
|
+
export declare const map: <KV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, VV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, K = ExtractValidatedType<KV>, V = ExtractValidatedType<VV>>(keyValidator?: KV, valueValidator?: VV, message?: string) => (value: Map<K, V>) => ValidateCoreReturnType<Map<K, V>>;
|
|
24
|
+
export {};
|