umt 3.0.0 → 3.2.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/Date/getDay.d.ts +1 -2
- package/module/Object/keyBy.d.ts +3 -4
- package/module/Validate/any/core.d.ts +2 -1
- package/module/Validate/any/core.js +3 -2
- package/module/Validate/any/core.js.map +1 -1
- package/module/Validate/array/arrayOf.d.ts +3 -3
- package/module/Validate/array/arrayOf.js +3 -1
- package/module/Validate/array/arrayOf.js.map +1 -1
- package/module/Validate/bigint/core.d.ts +2 -1
- package/module/Validate/bigint/core.js +3 -1
- package/module/Validate/bigint/core.js.map +1 -1
- package/module/Validate/boolean/core.d.ts +2 -1
- package/module/Validate/boolean/core.js +3 -1
- package/module/Validate/boolean/core.js.map +1 -1
- package/module/Validate/date/core.d.ts +2 -1
- package/module/Validate/date/core.js +3 -1
- package/module/Validate/date/core.js.map +1 -1
- package/module/Validate/file/core.d.ts +2 -1
- package/module/Validate/file/core.js +3 -1
- package/module/Validate/file/core.js.map +1 -1
- package/module/Validate/function/core.d.ts +11 -11
- package/module/Validate/function/core.js +2 -1
- package/module/Validate/function/core.js.map +1 -1
- package/module/Validate/index.d.ts +1 -0
- package/module/Validate/index.js +1 -0
- package/module/Validate/index.js.map +1 -1
- package/module/Validate/instanceof/core.d.ts +3 -3
- package/module/Validate/instanceof/core.js +3 -1
- package/module/Validate/instanceof/core.js.map +1 -1
- package/module/Validate/map/core.d.ts +3 -3
- package/module/Validate/map/core.js +3 -1
- package/module/Validate/map/core.js.map +1 -1
- package/module/Validate/never/core.d.ts +2 -1
- package/module/Validate/never/core.js +7 -8
- package/module/Validate/never/core.js.map +1 -1
- package/module/Validate/number/core.d.ts +3 -2
- package/module/Validate/number/core.js +3 -1
- package/module/Validate/number/core.js.map +1 -1
- package/module/Validate/object/core.d.ts +2 -1
- package/module/Validate/object/core.js +2 -1
- package/module/Validate/object/core.js.map +1 -1
- package/module/Validate/object/intersection.d.ts +5 -5
- package/module/Validate/object/intersection.js +3 -1
- package/module/Validate/object/intersection.js.map +1 -1
- package/module/Validate/object/nullable.d.ts +3 -3
- package/module/Validate/object/nullable.js +2 -1
- package/module/Validate/object/nullable.js.map +1 -1
- package/module/Validate/object/optional.d.ts +3 -3
- package/module/Validate/object/optional.js +2 -1
- package/module/Validate/object/optional.js.map +1 -1
- package/module/Validate/object/partial.d.ts +1 -2
- package/module/Validate/object/required.d.ts +2 -3
- package/module/Validate/object/union.d.ts +3 -3
- package/module/Validate/object/union.js +3 -1
- package/module/Validate/object/union.js.map +1 -1
- package/module/Validate/set/core.d.ts +3 -3
- package/module/Validate/set/core.js +3 -1
- package/module/Validate/set/core.js.map +1 -1
- package/module/Validate/standardSchema.d.ts +93 -0
- package/module/Validate/standardSchema.js +58 -0
- package/module/Validate/standardSchema.js.map +1 -0
- package/module/Validate/string/core.d.ts +3 -2
- package/module/Validate/string/core.js +5 -1
- package/module/Validate/string/core.js.map +1 -1
- package/module/Validate/templateLiteral/core.d.ts +7 -7
- package/module/Validate/templateLiteral/core.js +3 -1
- package/module/Validate/templateLiteral/core.js.map +1 -1
- package/module/Validate/unknown/core.d.ts +2 -1
- package/module/Validate/unknown/core.js +3 -1
- package/module/Validate/unknown/core.js.map +1 -1
- package/module/es5/Date/getDay.d.ts +1 -2
- package/module/es5/Object/keyBy.d.ts +3 -4
- package/module/es5/Validate/any/core.d.ts +2 -1
- package/module/es5/Validate/any/core.js +3 -2
- package/module/es5/Validate/array/arrayOf.d.ts +3 -3
- package/module/es5/Validate/array/arrayOf.js +3 -1
- package/module/es5/Validate/bigint/core.d.ts +2 -1
- package/module/es5/Validate/bigint/core.js +4 -4
- package/module/es5/Validate/boolean/core.d.ts +2 -1
- package/module/es5/Validate/boolean/core.js +3 -1
- package/module/es5/Validate/date/core.d.ts +2 -1
- package/module/es5/Validate/date/core.js +3 -1
- package/module/es5/Validate/file/core.d.ts +2 -1
- package/module/es5/Validate/file/core.js +3 -1
- package/module/es5/Validate/function/core.d.ts +11 -11
- package/module/es5/Validate/function/core.js +3 -6
- package/module/es5/Validate/index.d.ts +1 -0
- package/module/es5/Validate/index.js +11 -0
- package/module/es5/Validate/instanceof/core.d.ts +3 -3
- package/module/es5/Validate/instanceof/core.js +3 -1
- package/module/es5/Validate/map/core.d.ts +3 -3
- package/module/es5/Validate/map/core.js +4 -4
- package/module/es5/Validate/never/core.d.ts +2 -1
- package/module/es5/Validate/never/core.js +3 -2
- package/module/es5/Validate/number/core.d.ts +3 -2
- package/module/es5/Validate/number/core.js +3 -1
- package/module/es5/Validate/object/core.d.ts +2 -1
- package/module/es5/Validate/object/core.js +2 -1
- package/module/es5/Validate/object/intersection.d.ts +5 -5
- package/module/es5/Validate/object/intersection.js +3 -1
- package/module/es5/Validate/object/nullable.d.ts +3 -3
- package/module/es5/Validate/object/nullable.js +2 -1
- package/module/es5/Validate/object/optional.d.ts +3 -3
- package/module/es5/Validate/object/optional.js +2 -1
- package/module/es5/Validate/object/partial.d.ts +1 -2
- package/module/es5/Validate/object/required.d.ts +2 -3
- package/module/es5/Validate/object/union.d.ts +3 -3
- package/module/es5/Validate/object/union.js +3 -1
- package/module/es5/Validate/set/core.d.ts +3 -3
- package/module/es5/Validate/set/core.js +4 -4
- package/module/es5/Validate/standardSchema.d.ts +93 -0
- package/module/es5/Validate/standardSchema.js +91 -0
- package/module/es5/Validate/string/core.d.ts +3 -2
- package/module/es5/Validate/string/core.js +3 -1
- package/module/es5/Validate/templateLiteral/core.d.ts +7 -7
- package/module/es5/Validate/templateLiteral/core.js +7 -6
- package/module/es5/Validate/unknown/core.d.ts +2 -1
- package/module/es5/Validate/unknown/core.js +3 -1
- package/module/es5/types/array/chunk.d.ts +1 -2
- package/module/es5/types/array/zip.d.ts +4 -2
- package/module/es5/types/logic/binary1bitNor.d.ts +1 -2
- package/module/es5/types/logic/binaryFullAdder.d.ts +1 -2
- package/module/es5/types/math/divide.d.ts +1 -2
- package/module/es5/types/math/multiply.d.ts +1 -2
- package/module/es5/types/object/pickDeep.d.ts +3 -4
- package/module/types/array/chunk.d.ts +1 -2
- package/module/types/array/zip.d.ts +4 -2
- package/module/types/logic/binary1bitNor.d.ts +1 -2
- package/module/types/logic/binaryFullAdder.d.ts +1 -2
- package/module/types/math/divide.d.ts +1 -2
- package/module/types/math/multiply.d.ts +1 -2
- package/module/types/object/pickDeep.d.ts +3 -4
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/object/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/object/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AAyCnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,SAAY,EAAO,EACnB,OAAgB,EACyC,EAAE;IAW3D,MAAM,SAAS,GAAG,CAAC,CAAC,KAAe,EAAoC,EAAE;QACvE,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;YAC9B,6EAA6E;YAC7E,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAE,KAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACzD,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,6EAA6E;oBAC7E,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAY,CAAC,CAAC,OAAO;oBAC/C,kGAAkG;oBAClG,IAAI,EAAE,KAAY;iBACnB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,kGAAkG;YAClG,IAAI,EAAE,KAAY;SACnB,CAAC;IACJ,CAAC,CAAuB,CAAC;IAEzB,SAAS,CAAC,KAAK,GAAG,MAAM,CAAC;IACzB,OAAO,cAAc,CAAuC,SAAS,CAAC,CAAC;AACzE,CAAC,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
1
2
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
2
|
-
type
|
|
3
|
+
export type IntersectionExtractValidatedType<V> = V extends (value: never) => {
|
|
3
4
|
type: infer T;
|
|
4
5
|
} ? ValidateType<T> : never;
|
|
5
|
-
type IntersectValidatedTypes<Vs> = Vs extends readonly [
|
|
6
|
+
export type IntersectValidatedTypes<Vs> = Vs extends readonly [
|
|
6
7
|
infer Head,
|
|
7
8
|
...infer Tail
|
|
8
|
-
] ?
|
|
9
|
+
] ? IntersectionExtractValidatedType<Head> & IntersectValidatedTypes<Tail> : unknown;
|
|
9
10
|
/**
|
|
10
11
|
* Creates an intersection validator that passes only if all given validators pass
|
|
11
12
|
* @param validators - Validator functions to compose as an intersection (logical AND)
|
|
12
13
|
* @returns {Function} - Validator that checks if the value matches all validators
|
|
13
14
|
*/
|
|
14
|
-
export declare const intersection: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: IntersectValidatedTypes<Vs>) => ValidateCoreReturnType<IntersectValidatedTypes<Vs>>;
|
|
15
|
-
export {};
|
|
15
|
+
export declare const intersection: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => ((value: IntersectValidatedTypes<Vs>) => ValidateCoreReturnType<IntersectValidatedTypes<Vs>>) & StandardSchemaV1<IntersectValidatedTypes<Vs>, IntersectValidatedTypes<Vs>>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { attachStandard, } from "../../Validate/standardSchema";
|
|
1
2
|
/**
|
|
2
3
|
* Creates an intersection validator that passes only if all given validators pass
|
|
3
4
|
* @param validators - Validator functions to compose as an intersection (logical AND)
|
|
4
5
|
* @returns {Function} - Validator that checks if the value matches all validators
|
|
5
6
|
*/
|
|
6
7
|
export const intersection = (...validators) => {
|
|
7
|
-
|
|
8
|
+
const intersectionValidator = (value) => {
|
|
8
9
|
for (const validator of validators) {
|
|
9
10
|
const result = validator(value);
|
|
10
11
|
if (!result.validate) {
|
|
@@ -21,5 +22,6 @@ export const intersection = (...validators) => {
|
|
|
21
22
|
type: value,
|
|
22
23
|
};
|
|
23
24
|
};
|
|
25
|
+
return attachStandard(intersectionValidator);
|
|
24
26
|
};
|
|
25
27
|
//# sourceMappingURL=intersection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersection.js","sourceRoot":"","sources":["../../../src/Validate/object/intersection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intersection.js","sourceRoot":"","sources":["../../../src/Validate/object/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AA8BnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAG1B,GAAG,UAAmB,EAOpB,EAAE;IACJ,MAAM,qBAAqB,GAAG,CAC5B,KAAkC,EACmB,EAAE;QACvD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,MAAM,GACV,SAGD,CAAC,KAAK,CAAC,CAAC;YACT,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrB,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,IAAI,EAAE,KAAsD;iBAC7D,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAsD;SAC7D,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,cAAc,CAInB,qBAAqB,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
2
|
+
export interface NullReturn {
|
|
2
3
|
validate: boolean;
|
|
3
4
|
message: string;
|
|
4
5
|
type: "null";
|
|
@@ -14,5 +15,4 @@ export declare const nullable: <T, R extends {
|
|
|
14
15
|
type: unknown;
|
|
15
16
|
message: string;
|
|
16
17
|
validate: boolean;
|
|
17
|
-
}>(validator: (value: T) => R) => ((value: T | null) => R | NullReturn)
|
|
18
|
-
export {};
|
|
18
|
+
}>(validator: (value: T) => R) => ((value: T | null) => R | NullReturn) & StandardSchemaV1<T | null, T | null>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { attachStandard, } from "../../Validate/standardSchema";
|
|
1
2
|
/**
|
|
2
3
|
* Wraps a validator to accept null values
|
|
3
4
|
* @template T - The type of value the wrapped validator expects
|
|
@@ -16,6 +17,6 @@ export const nullable = (validator) => {
|
|
|
16
17
|
}
|
|
17
18
|
return validator(value);
|
|
18
19
|
};
|
|
19
|
-
return nullableValidator;
|
|
20
|
+
return attachStandard(nullableValidator);
|
|
20
21
|
};
|
|
21
22
|
//# sourceMappingURL=nullable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nullable.js","sourceRoot":"","sources":["../../../src/Validate/object/nullable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nullable.js","sourceRoot":"","sources":["../../../src/Validate/object/nullable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AAQnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAItB,SAA0B,EAEW,EAAE;IACvC,MAAM,iBAAiB,GAAG,CAAC,KAAe,EAAkB,EAAE;QAC5D,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,IAAI,EAAE,MAAM;aACb,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,cAAc,CACnB,iBAAiB,CAClB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
2
|
+
export interface UndefinedReturn {
|
|
2
3
|
validate: boolean;
|
|
3
4
|
message: string;
|
|
4
5
|
type: "undefined";
|
|
@@ -32,5 +33,4 @@ export declare const optional: <T, R extends {
|
|
|
32
33
|
type: unknown;
|
|
33
34
|
message: string;
|
|
34
35
|
validate: boolean;
|
|
35
|
-
}>(validator: (value: T) => R) => OptionalValidator<T, R>;
|
|
36
|
-
export {};
|
|
36
|
+
}>(validator: (value: T) => R) => OptionalValidator<T, R> & StandardSchemaV1<T | undefined, T | undefined>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { attachStandard, } from "../../Validate/standardSchema";
|
|
1
2
|
/**
|
|
2
3
|
* Wraps a validator to accept undefined values
|
|
3
4
|
* @template T - The type of value the wrapped validator expects
|
|
@@ -18,6 +19,6 @@ export const optional = (validator) => {
|
|
|
18
19
|
});
|
|
19
20
|
optionalValidator.inner = validator;
|
|
20
21
|
optionalValidator.isOptional = true;
|
|
21
|
-
return optionalValidator;
|
|
22
|
+
return attachStandard(optionalValidator);
|
|
22
23
|
};
|
|
23
24
|
//# sourceMappingURL=optional.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../src/Validate/object/optional.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../src/Validate/object/optional.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AA0BnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAItB,SAA0B,EACgD,EAAE;IAC5E,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAS,EAAuB,EAAE;QAC5D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,IAAI,EAAE,WAAW;aAClB,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAA4B,CAAC;IAE9B,iBAAiB,CAAC,KAAK,GAAG,SAAS,CAAC;IACpC,iBAAiB,CAAC,UAAU,GAAG,IAAI,CAAC;IAEpC,OAAO,cAAc,CACnB,iBAAiB,CAClB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type ObjectShape, type ObjectValidator } from "./core";
|
|
8
8
|
import { type OptionalValidator } from "./optional";
|
|
9
|
-
type PartialShape<T extends ObjectShape> = {
|
|
9
|
+
export type PartialShape<T extends ObjectShape> = {
|
|
10
10
|
[K in keyof T]: OptionalValidator<Parameters<T[K]>[0], ReturnType<T[K]> extends {
|
|
11
11
|
type: unknown;
|
|
12
12
|
message: string;
|
|
@@ -22,4 +22,3 @@ type PartialShape<T extends ObjectShape> = {
|
|
|
22
22
|
* @returns {ObjectValidator<PartialShape<T>>} - New validator where every key accepts undefined
|
|
23
23
|
*/
|
|
24
24
|
export declare const partial: <T extends ObjectShape>(validator: ObjectValidator<T>, message?: string) => ObjectValidator<PartialShape<T>>;
|
|
25
|
-
export {};
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type ObjectShape, type ObjectValidator } from "./core";
|
|
8
8
|
import type { OptionalValidator } from "./optional";
|
|
9
|
-
type UnwrapOptional<V> = V extends OptionalValidator<infer Inner, infer R> ? (value: Inner) => R : V;
|
|
10
|
-
type RequiredShape<T extends ObjectShape> = {
|
|
9
|
+
export type UnwrapOptional<V> = V extends OptionalValidator<infer Inner, infer R> ? (value: Inner) => R : V;
|
|
10
|
+
export type RequiredShape<T extends ObjectShape> = {
|
|
11
11
|
[K in keyof T]: UnwrapOptional<T[K]> extends ObjectShape[string] ? UnwrapOptional<T[K]> : T[K];
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -19,4 +19,3 @@ type RequiredShape<T extends ObjectShape> = {
|
|
|
19
19
|
* @returns {ObjectValidator<RequiredShape<T>>} - New validator where every optional layer is removed
|
|
20
20
|
*/
|
|
21
21
|
export declare const required: <T extends ObjectShape>(validator: ObjectValidator<T>, message?: string) => ObjectValidator<RequiredShape<T>>;
|
|
22
|
-
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
1
2
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
2
|
-
type
|
|
3
|
+
export type UnionExtractValidatedType<V> = V extends (value: never) => {
|
|
3
4
|
type: infer T;
|
|
4
5
|
} ? ValidateType<T> : never;
|
|
5
6
|
/**
|
|
@@ -7,5 +8,4 @@ type ExtractValidatedType<V> = V extends (value: never) => {
|
|
|
7
8
|
* @param validators - Validator functions to compose as a union (logical OR)
|
|
8
9
|
* @returns {Function} - Validator that checks if the value matches any of the validators
|
|
9
10
|
*/
|
|
10
|
-
export declare const union: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value:
|
|
11
|
-
export {};
|
|
11
|
+
export declare const union: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => ((value: UnionExtractValidatedType<Vs[number]>) => ValidateCoreReturnType<UnionExtractValidatedType<Vs[number]>>) & StandardSchemaV1<UnionExtractValidatedType<Vs[number]>, UnionExtractValidatedType<Vs[number]>>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { attachStandard, } from "../../Validate/standardSchema";
|
|
1
2
|
/**
|
|
2
3
|
* Creates a union validator that passes if any of the given validators pass
|
|
3
4
|
* @param validators - Validator functions to compose as a union (logical OR)
|
|
4
5
|
* @returns {Function} - Validator that checks if the value matches any of the validators
|
|
5
6
|
*/
|
|
6
7
|
export const union = (...validators) => {
|
|
7
|
-
|
|
8
|
+
const unionValidator = (value) => {
|
|
8
9
|
let lastMessage = "";
|
|
9
10
|
for (const validator of validators) {
|
|
10
11
|
const result = validator(value);
|
|
@@ -23,5 +24,6 @@ export const union = (...validators) => {
|
|
|
23
24
|
type: value,
|
|
24
25
|
};
|
|
25
26
|
};
|
|
27
|
+
return attachStandard(unionValidator);
|
|
26
28
|
};
|
|
27
29
|
//# sourceMappingURL=union.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../src/Validate/object/union.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../src/Validate/object/union.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AAkBnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAGnB,GAAG,UAAmB,EAOpB,EAAE;IACJ,MAAM,cAAc,GAAG,CACrB,KAA4C,EACmB,EAAE;QACjE,IAAI,WAAW,GAAG,EAAE,CAAC;QACrB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,MAAM,GACV,SAGD,CAAC,KAAK,CAAC,CAAC;YACT,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACpB,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,KAEL;iBACF,CAAC;YACJ,CAAC;YACD,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC;QAC/B,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,WAAW;YACpB,IAAI,EAAE,KAAgE;SACvE,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,cAAc,CAInB,cAAc,CAAC,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* The function is exported as `set_` because the top-level `Object` module
|
|
8
8
|
* already exposes a `set` runtime helper.
|
|
9
9
|
*/
|
|
10
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
10
11
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
11
|
-
type
|
|
12
|
+
export type SetExtractValidatedType<V> = V extends (value: never) => {
|
|
12
13
|
type: infer T;
|
|
13
14
|
} ? ValidateType<T> : never;
|
|
14
15
|
/**
|
|
@@ -20,5 +21,4 @@ type ExtractValidatedType<V> = V extends (value: never) => {
|
|
|
20
21
|
* @param {string} [message] - Custom error message for type validation
|
|
21
22
|
* @returns {Function} - Validator function for Set instances
|
|
22
23
|
*/
|
|
23
|
-
export declare const set_: <IV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, T =
|
|
24
|
-
export {};
|
|
24
|
+
export declare const set_: <IV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, T = SetExtractValidatedType<IV>>(itemValidator?: IV, message?: string) => ((value: Set<T>) => ValidateCoreReturnType<Set<T>>) & StandardSchemaV1<Set<T>, Set<T>>;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* The function is exported as `set_` because the top-level `Object` module
|
|
8
8
|
* already exposes a `set` runtime helper.
|
|
9
9
|
*/
|
|
10
|
+
import { attachStandard, } from "../../Validate/standardSchema";
|
|
10
11
|
/**
|
|
11
12
|
* Creates a Set validator. When a per-element validator is supplied, every
|
|
12
13
|
* element of the set must satisfy it; iteration short-circuits at the first
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
* @returns {Function} - Validator function for Set instances
|
|
18
19
|
*/
|
|
19
20
|
export const set_ = (itemValidator, message) => {
|
|
20
|
-
|
|
21
|
+
const setValidator = (value) => {
|
|
21
22
|
if (!(value instanceof Set)) {
|
|
22
23
|
return {
|
|
23
24
|
validate: false,
|
|
@@ -43,5 +44,6 @@ export const set_ = (itemValidator, message) => {
|
|
|
43
44
|
type: value,
|
|
44
45
|
};
|
|
45
46
|
};
|
|
47
|
+
return attachStandard(setValidator);
|
|
46
48
|
};
|
|
47
49
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/set/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/set/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AASnC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAOlB,aAAkB,EAClB,OAAgB,EAEiB,EAAE;IACnC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAkC,EAAE;QACrE,IAAI,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,IAAI,aAAa,EAAE,CAAC;YAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,MAAM,GACV,aAID,CAAC,IAAI,CAAC,CAAC;gBACR,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;oBACrB,OAAO;wBACL,QAAQ,EAAE,KAAK;wBACf,OAAO,EAAE,MAAM,CAAC,OAAO;wBACvB,IAAI,EAAE,KAAK;qBACZ,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,cAAc,CAAsC,YAAY,CAAC,CAAC;AAC3E,CAAC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard Schema V1 integration
|
|
3
|
+
*
|
|
4
|
+
* Defines the public Standard Schema V1 surface (https://standardschema.dev)
|
|
5
|
+
* and exposes the `attachStandard()` helper used by every UMT validator
|
|
6
|
+
* factory to advertise itself as a Standard Schema V1 implementation. The
|
|
7
|
+
* `~standard` property added by `attachStandard()` lets external tools
|
|
8
|
+
* (Zod-, Valibot-, ArkType-style ecosystems) consume UMT validators without
|
|
9
|
+
* adapters.
|
|
10
|
+
*
|
|
11
|
+
* Biome's `noNamespace` lint rule forbids TypeScript namespaces, so the spec
|
|
12
|
+
* is mirrored with flat interface/type names that remain structurally
|
|
13
|
+
* compatible with the official `StandardSchemaV1` interface published by
|
|
14
|
+
* `@standard-schema/spec`.
|
|
15
|
+
*/
|
|
16
|
+
/** The Standard Schema V1 interface. */
|
|
17
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
18
|
+
readonly "~standard": StandardSchemaV1Properties<Input, Output>;
|
|
19
|
+
}
|
|
20
|
+
/** The Standard Schema V1 properties interface. */
|
|
21
|
+
export interface StandardSchemaV1Properties<Input = unknown, Output = Input> {
|
|
22
|
+
/** The version number of the standard. */
|
|
23
|
+
readonly version: 1;
|
|
24
|
+
/** The vendor name of the schema library. */
|
|
25
|
+
readonly vendor: string;
|
|
26
|
+
/** Validates unknown input values. */
|
|
27
|
+
readonly validate: (value: unknown) => StandardSchemaV1Result<Output> | Promise<StandardSchemaV1Result<Output>>;
|
|
28
|
+
/** Inferred types associated with the schema. */
|
|
29
|
+
readonly types?: StandardSchemaV1Types<Input, Output> | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** The result type produced by `Props.validate`. */
|
|
32
|
+
export type StandardSchemaV1Result<Output> = StandardSchemaV1SuccessResult<Output> | StandardSchemaV1FailureResult;
|
|
33
|
+
/** The result interface when validation succeeds. */
|
|
34
|
+
export interface StandardSchemaV1SuccessResult<Output> {
|
|
35
|
+
readonly value: Output;
|
|
36
|
+
readonly issues?: undefined;
|
|
37
|
+
}
|
|
38
|
+
/** The result interface when validation fails. */
|
|
39
|
+
export interface StandardSchemaV1FailureResult {
|
|
40
|
+
readonly issues: readonly StandardSchemaV1Issue[];
|
|
41
|
+
}
|
|
42
|
+
/** The issue interface returned on failure. */
|
|
43
|
+
export interface StandardSchemaV1Issue {
|
|
44
|
+
readonly message: string;
|
|
45
|
+
readonly path?: readonly (PropertyKey | StandardSchemaV1PathSegment)[] | undefined;
|
|
46
|
+
}
|
|
47
|
+
/** The path segment interface for nested issues. */
|
|
48
|
+
export interface StandardSchemaV1PathSegment {
|
|
49
|
+
readonly key: PropertyKey;
|
|
50
|
+
}
|
|
51
|
+
/** The Standard Schema V1 types interface. */
|
|
52
|
+
export interface StandardSchemaV1Types<Input = unknown, Output = Input> {
|
|
53
|
+
/** The input type of the schema. */
|
|
54
|
+
readonly input: Input;
|
|
55
|
+
/** The output type of the schema. */
|
|
56
|
+
readonly output: Output;
|
|
57
|
+
}
|
|
58
|
+
/** Infers the input type of a Standard Schema V1 implementation. */
|
|
59
|
+
export type StandardSchemaV1InferInput<Schema extends StandardSchemaV1<any, any>> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
60
|
+
/** Infers the output type of a Standard Schema V1 implementation. */
|
|
61
|
+
export type StandardSchemaV1InferOutput<Schema extends StandardSchemaV1<any, any>> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
62
|
+
/**
|
|
63
|
+
* Vendor identifier used by all UMT validators when advertising Standard
|
|
64
|
+
* Schema V1 compatibility. External tools may key off this value to attach
|
|
65
|
+
* UMT-specific behavior.
|
|
66
|
+
*/
|
|
67
|
+
export declare const STANDARD_SCHEMA_VENDOR = "umt";
|
|
68
|
+
/** Minimal shape of UMT validator results consumed by `attachStandard`. */
|
|
69
|
+
export interface UmtValidatorResult {
|
|
70
|
+
validate: boolean;
|
|
71
|
+
message: string;
|
|
72
|
+
type: unknown;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Attaches a Standard Schema V1 `~standard` property to a UMT validator
|
|
76
|
+
* function in place. The validator's existing call signature, attached
|
|
77
|
+
* helpers (such as `shape` on `object()` or `implement` on `function_()`),
|
|
78
|
+
* and return type are preserved untouched; only the `~standard` property is
|
|
79
|
+
* added.
|
|
80
|
+
*
|
|
81
|
+
* Validation is delegated to the wrapped validator. On success the input
|
|
82
|
+
* value is returned through the Standard Schema `value` field; on failure a
|
|
83
|
+
* single issue carrying the validator's message is emitted. UMT validators
|
|
84
|
+
* never transform their input, so `Input` and `Output` default to the same
|
|
85
|
+
* type.
|
|
86
|
+
*
|
|
87
|
+
* @template Input - The input type advertised through `~standard.types`
|
|
88
|
+
* @template Output - The output type advertised through `~standard.types`
|
|
89
|
+
* @template F - The validator function being augmented
|
|
90
|
+
* @param {F} validator - The validator function to augment
|
|
91
|
+
* @returns {F & StandardSchemaV1<Input, Output>} The same function with `~standard` attached
|
|
92
|
+
*/
|
|
93
|
+
export declare const attachStandard: <Input, Output = Input, F extends (...arguments_: any[]) => UmtValidatorResult = (...arguments_: any[]) => UmtValidatorResult>(validator: F) => F & StandardSchemaV1<Input, Output>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard Schema V1 integration
|
|
3
|
+
*
|
|
4
|
+
* Defines the public Standard Schema V1 surface (https://standardschema.dev)
|
|
5
|
+
* and exposes the `attachStandard()` helper used by every UMT validator
|
|
6
|
+
* factory to advertise itself as a Standard Schema V1 implementation. The
|
|
7
|
+
* `~standard` property added by `attachStandard()` lets external tools
|
|
8
|
+
* (Zod-, Valibot-, ArkType-style ecosystems) consume UMT validators without
|
|
9
|
+
* adapters.
|
|
10
|
+
*
|
|
11
|
+
* Biome's `noNamespace` lint rule forbids TypeScript namespaces, so the spec
|
|
12
|
+
* is mirrored with flat interface/type names that remain structurally
|
|
13
|
+
* compatible with the official `StandardSchemaV1` interface published by
|
|
14
|
+
* `@standard-schema/spec`.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Vendor identifier used by all UMT validators when advertising Standard
|
|
18
|
+
* Schema V1 compatibility. External tools may key off this value to attach
|
|
19
|
+
* UMT-specific behavior.
|
|
20
|
+
*/
|
|
21
|
+
export const STANDARD_SCHEMA_VENDOR = "umt";
|
|
22
|
+
/**
|
|
23
|
+
* Attaches a Standard Schema V1 `~standard` property to a UMT validator
|
|
24
|
+
* function in place. The validator's existing call signature, attached
|
|
25
|
+
* helpers (such as `shape` on `object()` or `implement` on `function_()`),
|
|
26
|
+
* and return type are preserved untouched; only the `~standard` property is
|
|
27
|
+
* added.
|
|
28
|
+
*
|
|
29
|
+
* Validation is delegated to the wrapped validator. On success the input
|
|
30
|
+
* value is returned through the Standard Schema `value` field; on failure a
|
|
31
|
+
* single issue carrying the validator's message is emitted. UMT validators
|
|
32
|
+
* never transform their input, so `Input` and `Output` default to the same
|
|
33
|
+
* type.
|
|
34
|
+
*
|
|
35
|
+
* @template Input - The input type advertised through `~standard.types`
|
|
36
|
+
* @template Output - The output type advertised through `~standard.types`
|
|
37
|
+
* @template F - The validator function being augmented
|
|
38
|
+
* @param {F} validator - The validator function to augment
|
|
39
|
+
* @returns {F & StandardSchemaV1<Input, Output>} The same function with `~standard` attached
|
|
40
|
+
*/
|
|
41
|
+
export const attachStandard = (validator) => {
|
|
42
|
+
const properties = {
|
|
43
|
+
version: 1,
|
|
44
|
+
vendor: STANDARD_SCHEMA_VENDOR,
|
|
45
|
+
validate: (value) => {
|
|
46
|
+
const result = validator(value);
|
|
47
|
+
if (result.validate) {
|
|
48
|
+
return { value: value };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
issues: [{ message: result.message || "Validation failed" }],
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
validator["~standard"] = properties;
|
|
56
|
+
return validator;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=standardSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standardSchema.js","sourceRoot":"","sources":["../../src/Validate/standardSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAsEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAS5C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAS5B,SAAY,EACyB,EAAE;IACvC,MAAM,UAAU,GAA8C;QAC5D,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,sBAAsB;QAC9B,QAAQ,EAAE,CAAC,KAAc,EAAkC,EAAE;YAC3D,MAAM,MAAM,GACV,SACD,CAAC,KAAK,CAAC,CAAC;YACT,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACpB,OAAO,EAAE,KAAK,EAAE,KAAe,EAAE,CAAC;YACpC,CAAC;YACD,OAAO;gBACL,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,mBAAmB,EAAE,CAAC;aAC7D,CAAC;QACJ,CAAC;KACF,CAAC;IACD,SAAgD,CAAC,WAAW,CAAC,GAAG,UAAU,CAAC;IAC5E,OAAO,SAAgD,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* String validation core module
|
|
3
3
|
* Provides the base validation functionality for string values
|
|
4
4
|
*/
|
|
5
|
-
import type
|
|
5
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
6
|
+
import type { ValidateCoreReturnType, ValidateReturnType } from "../../Validate/type";
|
|
6
7
|
/**
|
|
7
8
|
* Creates a string validator with optional validation rules
|
|
8
9
|
* @template T - Array of validation rules for strings
|
|
@@ -10,4 +11,4 @@ import type { ValidateReturnType } from "../../Validate/type";
|
|
|
10
11
|
* @param {string} [message] - Custom error message for type validation
|
|
11
12
|
* @returns {Function} - Validator function that checks if the value is a string and applies validation rules
|
|
12
13
|
*/
|
|
13
|
-
export declare const string: <T extends ValidateReturnType<string>[]>(option?: T, message?: string) => (value: string) =>
|
|
14
|
+
export declare const string: <T extends ValidateReturnType<string>[]>(option?: T, message?: string) => ((value: string) => ValidateCoreReturnType<string>) & StandardSchemaV1<string, string>;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provides the base validation functionality for string values
|
|
4
4
|
*/
|
|
5
5
|
import { core } from "../../Validate/core";
|
|
6
|
+
import { attachStandard, } from "../../Validate/standardSchema";
|
|
6
7
|
/**
|
|
7
8
|
* Creates a string validator with optional validation rules
|
|
8
9
|
* @template T - Array of validation rules for strings
|
|
@@ -10,5 +11,8 @@ import { core } from "../../Validate/core";
|
|
|
10
11
|
* @param {string} [message] - Custom error message for type validation
|
|
11
12
|
* @returns {Function} - Validator function that checks if the value is a string and applies validation rules
|
|
12
13
|
*/
|
|
13
|
-
export const string = (option, message) =>
|
|
14
|
+
export const string = (option, message) => {
|
|
15
|
+
const validator = (value) => core("string")(value, option, message);
|
|
16
|
+
return attachStandard(validator);
|
|
17
|
+
};
|
|
14
18
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/string/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/string/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AAMnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,MAAU,EACV,OAAgB,EAEiB,EAAE;IACnC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAClC,IAAI,CAAS,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACjD,OAAO,cAAc,CAAmC,SAAS,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* an auto-generated regular expression assembled from the parts, while the
|
|
7
7
|
* inferred type is the corresponding TypeScript template literal type.
|
|
8
8
|
*/
|
|
9
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
9
10
|
import type { ValidateType } from "../../Validate/type";
|
|
10
|
-
type
|
|
11
|
+
export type TemplateLiteralAnyValidator = (value?: any) => {
|
|
11
12
|
type: unknown;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
@@ -15,12 +16,12 @@ type AnyValidator = (value?: any) => {
|
|
|
15
16
|
* string literal that must appear verbatim, or a primitive validator whose
|
|
16
17
|
* accepted shape is converted to a regex fragment at construction time.
|
|
17
18
|
*/
|
|
18
|
-
export type TemplateLiteralPart = string |
|
|
19
|
-
type ExtractValidatorTag<V> = V extends (value: never) => {
|
|
19
|
+
export type TemplateLiteralPart = string | TemplateLiteralAnyValidator;
|
|
20
|
+
export type ExtractValidatorTag<V> = V extends (value: never) => {
|
|
20
21
|
type: infer T;
|
|
21
22
|
} ? T : never;
|
|
22
|
-
type TagToTemplate<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "bigint" ? bigint : ValidateType<T>;
|
|
23
|
-
type PartToTemplate<P> = P extends string ? P : TagToTemplate<ExtractValidatorTag<P>>;
|
|
23
|
+
export type TagToTemplate<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "bigint" ? bigint : ValidateType<T>;
|
|
24
|
+
export type PartToTemplate<P> = P extends string ? P : TagToTemplate<ExtractValidatorTag<P>>;
|
|
24
25
|
/**
|
|
25
26
|
* Builds the template literal type produced by joining `Parts`. Each part is
|
|
26
27
|
* mapped to either its literal string value or to the runtime type that the
|
|
@@ -51,5 +52,4 @@ export interface TemplateLiteralReturnType<T extends string> {
|
|
|
51
52
|
* @param {string} [message] - Custom error message for validation failure
|
|
52
53
|
* @returns {Function} - Validator function for template literal strings
|
|
53
54
|
*/
|
|
54
|
-
export declare const templateLiteral: <const Parts extends readonly TemplateLiteralPart[]>(parts: Parts, message?: string) => (value: BuildTemplateLiteral<Parts>) => TemplateLiteralReturnType<BuildTemplateLiteral<Parts>>;
|
|
55
|
-
export {};
|
|
55
|
+
export declare const templateLiteral: <const Parts extends readonly TemplateLiteralPart[]>(parts: Parts, message?: string) => ((value: BuildTemplateLiteral<Parts>) => TemplateLiteralReturnType<BuildTemplateLiteral<Parts>>) & StandardSchemaV1<BuildTemplateLiteral<Parts>, BuildTemplateLiteral<Parts>>;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* an auto-generated regular expression assembled from the parts, while the
|
|
7
7
|
* inferred type is the corresponding TypeScript template literal type.
|
|
8
8
|
*/
|
|
9
|
+
import { attachStandard, } from "../../Validate/standardSchema";
|
|
9
10
|
const escapeRegex = (input) => input.replaceAll(/[$()*+.?[\\\]^{|}]/g, String.raw `\$&`);
|
|
10
11
|
const tagToPattern = (tag) => {
|
|
11
12
|
switch (tag) {
|
|
@@ -50,7 +51,7 @@ export const templateLiteral = (parts, message) => {
|
|
|
50
51
|
}
|
|
51
52
|
pattern += "$";
|
|
52
53
|
const regex = new RegExp(pattern);
|
|
53
|
-
|
|
54
|
+
const templateValidator = (value) => {
|
|
54
55
|
if (typeof value !== "string" || !regex.test(value)) {
|
|
55
56
|
return {
|
|
56
57
|
validate: false,
|
|
@@ -64,5 +65,6 @@ export const templateLiteral = (parts, message) => {
|
|
|
64
65
|
type: value,
|
|
65
66
|
};
|
|
66
67
|
};
|
|
68
|
+
return attachStandard(templateValidator);
|
|
67
69
|
};
|
|
68
70
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/templateLiteral/core.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/templateLiteral/core.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AA0DnC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE,CAC5C,KAAK,CAAC,UAAU,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAAG,CAAA,KAAK,CAAC,CAAC;AAE3D,MAAM,YAAY,GAAG,CAAC,GAAY,EAAU,EAAE;IAC5C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,MAAM,CAAC,GAAG,CAAA,oCAAoC,CAAC;QACxD,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,MAAM,CAAC,GAAG,CAAA,OAAO,CAAC;QAC3B,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,SAAsC,EAC7B,EAAE;IACX,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,MAAM,EAAE,IAAI,CAAC;AACtB,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAG7B,KAAY,EACZ,OAAgB,EAOd,EAAE;IACJ,IAAI,OAAO,GAAG,GAAG,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,OAAO;YACL,OAAO,IAAI,KAAK,QAAQ;gBACtB,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;gBACnB,CAAC,CAAC,MAAM,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,GAAG,CAAC;IACf,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;IAElC,MAAM,iBAAiB,GAAG,CACxB,KAAkC,EACsB,EAAE;QAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACpD,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;IACF,OAAO,cAAc,CAInB,iBAAiB,CAAC,CAAC;AACvB,CAAC,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provides a validator that accepts any value but exposes it as `unknown`
|
|
4
4
|
* to keep callers honest about narrowing before use.
|
|
5
5
|
*/
|
|
6
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
6
7
|
/**
|
|
7
8
|
* Return type produced by an `unknown` validator. Exposes the literal
|
|
8
9
|
* `"unknown"` tag through the `type` field so `ValidateType<"unknown">` can
|
|
@@ -18,4 +19,4 @@ export interface UnknownReturnType {
|
|
|
18
19
|
* Creates a validator that accepts any value but typed as unknown
|
|
19
20
|
* @returns {Function} - Validator that always succeeds
|
|
20
21
|
*/
|
|
21
|
-
export declare const unknown: () => ((value: unknown) => UnknownReturnType)
|
|
22
|
+
export declare const unknown: () => ((value: unknown) => UnknownReturnType) & StandardSchemaV1<unknown, unknown>;
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
* Provides a validator that accepts any value but exposes it as `unknown`
|
|
4
4
|
* to keep callers honest about narrowing before use.
|
|
5
5
|
*/
|
|
6
|
+
import { attachStandard, } from "../../Validate/standardSchema";
|
|
6
7
|
const unknownValidator = (_value) => ({
|
|
7
8
|
validate: true,
|
|
8
9
|
message: "",
|
|
9
10
|
type: "unknown",
|
|
10
11
|
});
|
|
12
|
+
const standardUnknownValidator = attachStandard(unknownValidator);
|
|
11
13
|
/**
|
|
12
14
|
* Creates a validator that accepts any value but typed as unknown
|
|
13
15
|
* @returns {Function} - Validator that always succeeds
|
|
14
16
|
*/
|
|
15
|
-
export const unknown = () =>
|
|
17
|
+
export const unknown = () => standardUnknownValidator;
|
|
16
18
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/unknown/core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/unknown/core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,GAEf,MAAM,2BAA2B,CAAC;AAcnC,MAAM,gBAAgB,GAAG,CAAC,MAAe,EAAqB,EAAE,CAAC,CAAC;IAChE,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,SAAS;CAChB,CAAC,CAAC;AAEH,MAAM,wBAAwB,GAAG,cAAc,CAI7C,gBAAgB,CAAC,CAAC;AAEpB;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GACc,EAAE,CAAC,wBAAwB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArrayToUnion } from "../types/logic/arrayToUnion";
|
|
2
|
-
interface DayList {
|
|
2
|
+
export interface DayList {
|
|
3
3
|
de: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
|
|
4
4
|
ko: ["일", "월", "화", "수", "목", "금", "토"];
|
|
5
5
|
en: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
@@ -17,4 +17,3 @@ interface DayList {
|
|
|
17
17
|
* getDay(1, "fr"); // Returns "Lun"
|
|
18
18
|
*/
|
|
19
19
|
export declare const getDay: <T extends keyof DayList>(day: number, lang?: T) => ArrayToUnion<DayList[T]>;
|
|
20
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
type PropertyName = string | number | symbol;
|
|
2
|
-
type IterateeFunction<T> = (value: T) => PropertyName;
|
|
3
|
-
type Iteratee<T> = IterateeFunction<T> | keyof T;
|
|
1
|
+
export type PropertyName = string | number | symbol;
|
|
2
|
+
export type IterateeFunction<T> = (value: T) => PropertyName;
|
|
3
|
+
export type Iteratee<T> = IterateeFunction<T> | keyof T;
|
|
4
4
|
/**
|
|
5
5
|
* Creates an object composed of keys generated from the results of running each element of collection through iteratee
|
|
6
6
|
* @param collection The collection to iterate over
|
|
@@ -17,4 +17,3 @@ type Iteratee<T> = IterateeFunction<T> | keyof T;
|
|
|
17
17
|
* - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
|
|
18
18
|
*/
|
|
19
19
|
export declare function keyBy<T>(collection: T[] | Record<PropertyName, T>, iteratee?: Iteratee<T>): Record<PropertyName, T>;
|
|
20
|
-
export {};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* schema needs to remain wide open while still participating in `object()`,
|
|
5
5
|
* `union()`, `intersection()`, and other compositional helpers.
|
|
6
6
|
*/
|
|
7
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
7
8
|
/**
|
|
8
9
|
* Return type produced by an `any` validator. Exposes the literal `"any"`
|
|
9
10
|
* tag through the `type` field so `ValidateType<"any">` can map it back to
|
|
@@ -18,4 +19,4 @@ export interface AnyReturnType {
|
|
|
18
19
|
* Creates a validator that accepts any value
|
|
19
20
|
* @returns {Function} - Validator that always succeeds
|
|
20
21
|
*/
|
|
21
|
-
export declare const any: () => ((value: any) => AnyReturnType)
|
|
22
|
+
export declare const any: () => ((value: any) => AnyReturnType) & StandardSchemaV1<any, any>;
|