@sinclair/typebox 0.32.0-dev-25 → 0.32.0-dev-27
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/build/import/errors/errors.mjs +2 -2
- package/build/import/errors/function.d.mts +13 -3
- package/build/import/errors/function.mjs +39 -39
- package/build/import/index.d.mts +2 -2
- package/build/import/type/awaited/awaited.mjs +2 -6
- package/build/import/type/composite/composite.d.mts +1 -2
- package/build/import/type/composite/composite.mjs +2 -2
- package/build/import/type/const/const.mjs +6 -6
- package/build/import/type/constructor/constructor.d.mts +1 -1
- package/build/import/type/constructor/constructor.mjs +1 -1
- package/build/import/type/deref/deref.mjs +1 -2
- package/build/import/type/discard/discard.mjs +2 -2
- package/build/import/type/enum/enum.mjs +3 -0
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +5 -5
- package/build/import/type/exclude/exclude-from-mapped-result.mjs +7 -7
- package/build/import/type/exclude/exclude.mjs +0 -1
- package/build/import/type/extends/extends-from-mapped-key.d.mts +1 -1
- package/build/import/type/extends/extends-from-mapped-key.mjs +4 -5
- package/build/import/type/extends/extends-from-mapped-result.d.mts +5 -5
- package/build/import/type/extends/extends-from-mapped-result.mjs +7 -7
- package/build/import/type/extends/extends.mjs +0 -1
- package/build/import/type/extract/extract-from-mapped-result.d.mts +5 -5
- package/build/import/type/extract/extract-from-mapped-result.mjs +7 -7
- package/build/import/type/extract/extract.d.mts +1 -2
- package/build/import/type/extract/extract.mjs +4 -2
- package/build/import/type/index.d.mts +1 -1
- package/build/import/type/index.mjs +1 -1
- package/build/import/type/indexed/indexed-from-mapped-key.d.mts +2 -2
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +4 -5
- package/build/import/type/indexed/indexed-from-mapped-result.d.mts +2 -2
- package/build/import/type/indexed/indexed-from-mapped-result.mjs +1 -1
- package/build/import/type/indexed/indexed-property-keys.d.mts +6 -6
- package/build/import/type/indexed/indexed-property-keys.mjs +3 -5
- package/build/import/type/indexed/indexed.d.mts +1 -1
- package/build/import/type/indexed/indexed.mjs +9 -27
- package/build/import/type/intersect/intersect-evaluated.mjs +3 -13
- package/build/import/type/intrinsic/capitalize.d.mts +2 -2
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +1 -1
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +4 -5
- package/build/import/type/intrinsic/intrinsic.d.mts +2 -3
- package/build/import/type/intrinsic/intrinsic.mjs +2 -5
- package/build/import/type/intrinsic/lowercase.d.mts +2 -2
- package/build/import/type/intrinsic/uncapitalize.d.mts +2 -2
- package/build/import/type/intrinsic/uppercase.d.mts +2 -2
- package/build/import/type/iterator/iterator.mjs +1 -1
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +3 -3
- package/build/import/type/keyof/keyof-from-mapped-result.mjs +4 -4
- package/build/import/type/keyof/keyof-property-keys.d.mts +3 -3
- package/build/import/type/keyof/keyof-property-keys.mjs +9 -15
- package/build/import/type/keyof/keyof.mjs +2 -8
- package/build/import/type/mapped/mapped.d.mts +6 -1
- package/build/import/type/mapped/mapped.mjs +21 -14
- package/build/import/type/not/not.mjs +1 -1
- package/build/import/type/object/object.d.mts +1 -1
- package/build/import/type/object/object.mjs +0 -1
- package/build/import/type/omit/index.d.mts +1 -0
- package/build/import/type/omit/index.mjs +1 -0
- package/build/import/type/omit/omit-from-mapped-key.mjs +4 -5
- package/build/import/type/omit/omit-from-mapped-result.d.mts +11 -0
- package/build/import/type/omit/omit-from-mapped-result.mjs +17 -0
- package/build/import/type/omit/omit.d.mts +6 -3
- package/build/import/type/omit/omit.mjs +11 -9
- package/build/import/type/optional/optional-from-mapped-result.d.mts +5 -5
- package/build/import/type/optional/optional-from-mapped-result.mjs +7 -7
- package/build/import/type/partial/partial-from-mapped-result.d.mts +5 -5
- package/build/import/type/partial/partial-from-mapped-result.mjs +4 -4
- package/build/import/type/partial/partial.d.mts +2 -3
- package/build/import/type/partial/partial.mjs +8 -21
- package/build/import/type/pick/index.d.mts +1 -0
- package/build/import/type/pick/index.mjs +1 -0
- package/build/import/type/pick/pick-from-mapped-key.mjs +4 -5
- package/build/import/type/pick/pick-from-mapped-result.d.mts +11 -0
- package/build/import/type/pick/pick-from-mapped-result.mjs +17 -0
- package/build/import/type/pick/pick.d.mts +5 -2
- package/build/import/type/pick/pick.mjs +11 -10
- package/build/import/type/promise/promise.mjs +1 -1
- package/build/import/type/readonly/readonly-from-mapped-result.d.mts +5 -5
- package/build/import/type/readonly/readonly-from-mapped-result.mjs +4 -4
- package/build/import/type/record/record.d.mts +2 -2
- package/build/import/type/record/record.mjs +3 -0
- package/build/import/type/ref/ref.mjs +1 -1
- package/build/import/type/required/required-from-mapped-result.d.mts +5 -5
- package/build/import/type/required/required-from-mapped-result.mjs +7 -7
- package/build/import/type/required/required.d.mts +2 -3
- package/build/import/type/required/required.mjs +4 -14
- package/build/import/type/rest/rest.d.mts +2 -2
- package/build/import/type/rest/rest.mjs +1 -2
- package/build/import/type/sets/index.d.mts +1 -0
- package/build/import/type/sets/index.mjs +1 -0
- package/build/import/type/sets/set.d.mts +24 -0
- package/build/import/type/sets/set.mjs +35 -0
- package/build/import/type/strict/strict.d.mts +1 -1
- package/build/import/type/strict/strict.mjs +1 -1
- package/build/import/type/template-literal/syntax.d.mts +1 -1
- package/build/import/type/template-literal/template-literal.d.mts +1 -1
- package/build/import/type/transform/transform.mjs +1 -1
- package/build/import/type/type/json.d.mts +6 -2
- package/build/import/type/union/union-evaluated.mjs +3 -14
- package/build/require/errors/errors.js +2 -2
- package/build/require/errors/function.d.ts +13 -3
- package/build/require/errors/function.js +39 -39
- package/build/require/index.d.ts +2 -2
- package/build/require/type/awaited/awaited.js +2 -6
- package/build/require/type/composite/composite.d.ts +1 -2
- package/build/require/type/composite/composite.js +5 -6
- package/build/require/type/const/const.js +6 -6
- package/build/require/type/constructor/constructor.d.ts +1 -1
- package/build/require/type/constructor/constructor.js +1 -1
- package/build/require/type/deref/deref.js +0 -1
- package/build/require/type/discard/discard.js +2 -2
- package/build/require/type/enum/enum.js +3 -0
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +5 -5
- package/build/require/type/exclude/exclude-from-mapped-result.js +7 -7
- package/build/require/type/exclude/exclude.js +0 -1
- package/build/require/type/extends/extends-from-mapped-key.d.ts +1 -1
- package/build/require/type/extends/extends-from-mapped-key.js +4 -5
- package/build/require/type/extends/extends-from-mapped-result.d.ts +5 -5
- package/build/require/type/extends/extends-from-mapped-result.js +7 -7
- package/build/require/type/extends/extends.js +0 -1
- package/build/require/type/extract/extract-from-mapped-result.d.ts +5 -5
- package/build/require/type/extract/extract-from-mapped-result.js +7 -7
- package/build/require/type/extract/extract.d.ts +1 -2
- package/build/require/type/extract/extract.js +4 -3
- package/build/require/type/index.d.ts +1 -1
- package/build/require/type/index.js +1 -1
- package/build/require/type/indexed/indexed-from-mapped-key.d.ts +2 -2
- package/build/require/type/indexed/indexed-from-mapped-key.js +4 -5
- package/build/require/type/indexed/indexed-from-mapped-result.d.ts +2 -2
- package/build/require/type/indexed/indexed-from-mapped-result.js +1 -1
- package/build/require/type/indexed/indexed-property-keys.d.ts +6 -6
- package/build/require/type/indexed/indexed-property-keys.js +3 -5
- package/build/require/type/indexed/indexed.d.ts +1 -1
- package/build/require/type/indexed/indexed.js +9 -27
- package/build/require/type/intersect/intersect-evaluated.js +3 -13
- package/build/require/type/intrinsic/capitalize.d.ts +2 -2
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +1 -1
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +4 -5
- package/build/require/type/intrinsic/intrinsic.d.ts +2 -3
- package/build/require/type/intrinsic/intrinsic.js +2 -5
- package/build/require/type/intrinsic/lowercase.d.ts +2 -2
- package/build/require/type/intrinsic/uncapitalize.d.ts +2 -2
- package/build/require/type/intrinsic/uppercase.d.ts +2 -2
- package/build/require/type/iterator/iterator.js +1 -1
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +3 -3
- package/build/require/type/keyof/keyof-from-mapped-result.js +4 -4
- package/build/require/type/keyof/keyof-property-keys.d.ts +3 -3
- package/build/require/type/keyof/keyof-property-keys.js +9 -15
- package/build/require/type/keyof/keyof.js +2 -8
- package/build/require/type/mapped/mapped.d.ts +6 -1
- package/build/require/type/mapped/mapped.js +21 -14
- package/build/require/type/not/not.js +1 -1
- package/build/require/type/object/object.d.ts +1 -1
- package/build/require/type/object/object.js +0 -1
- package/build/require/type/omit/index.d.ts +1 -0
- package/build/require/type/omit/index.js +1 -0
- package/build/require/type/omit/omit-from-mapped-key.js +4 -5
- package/build/require/type/omit/omit-from-mapped-result.d.ts +11 -0
- package/build/require/type/omit/omit-from-mapped-result.js +22 -0
- package/build/require/type/omit/omit.d.ts +6 -3
- package/build/require/type/omit/omit.js +10 -8
- package/build/require/type/optional/optional-from-mapped-result.d.ts +5 -5
- package/build/require/type/optional/optional-from-mapped-result.js +7 -7
- package/build/require/type/partial/partial-from-mapped-result.d.ts +5 -5
- package/build/require/type/partial/partial-from-mapped-result.js +4 -4
- package/build/require/type/partial/partial.d.ts +2 -3
- package/build/require/type/partial/partial.js +8 -21
- package/build/require/type/pick/index.d.ts +1 -0
- package/build/require/type/pick/index.js +1 -0
- package/build/require/type/pick/pick-from-mapped-key.js +4 -5
- package/build/require/type/pick/pick-from-mapped-result.d.ts +11 -0
- package/build/require/type/pick/pick-from-mapped-result.js +22 -0
- package/build/require/type/pick/pick.d.ts +5 -2
- package/build/require/type/pick/pick.js +10 -9
- package/build/require/type/promise/promise.js +1 -1
- package/build/require/type/readonly/readonly-from-mapped-result.d.ts +5 -5
- package/build/require/type/readonly/readonly-from-mapped-result.js +4 -4
- package/build/require/type/record/record.d.ts +2 -2
- package/build/require/type/record/record.js +3 -0
- package/build/require/type/ref/ref.js +1 -1
- package/build/require/type/required/required-from-mapped-result.d.ts +5 -5
- package/build/require/type/required/required-from-mapped-result.js +7 -7
- package/build/require/type/required/required.d.ts +2 -3
- package/build/require/type/required/required.js +4 -14
- package/build/require/type/rest/rest.d.ts +2 -2
- package/build/require/type/rest/rest.js +1 -3
- package/build/require/type/sets/index.d.ts +1 -0
- package/build/require/type/{operators → sets}/index.js +1 -1
- package/build/require/type/sets/set.d.ts +24 -0
- package/build/require/type/sets/set.js +47 -0
- package/build/require/type/strict/strict.d.ts +1 -1
- package/build/require/type/strict/strict.js +1 -1
- package/build/require/type/template-literal/parse.js +1 -1
- package/build/require/type/template-literal/syntax.d.ts +1 -1
- package/build/require/type/template-literal/template-literal.d.ts +1 -1
- package/build/require/type/transform/transform.js +1 -1
- package/build/require/type/type/json.d.ts +6 -2
- package/build/require/type/union/union-evaluated.js +3 -14
- package/package.json +1 -1
- package/readme.md +67 -67
- package/build/import/type/operators/index.d.mts +0 -1
- package/build/import/type/operators/index.mjs +0 -1
- package/build/import/type/operators/operators.d.mts +0 -24
- package/build/import/type/operators/operators.mjs +0 -77
- package/build/require/type/operators/index.d.ts +0 -1
- package/build/require/type/operators/operators.d.ts +0 -24
- package/build/require/type/operators/operators.js +0 -89
|
@@ -21,10 +21,10 @@ import { type TNull } from '../null/index.mjs';
|
|
|
21
21
|
import { type TMappedKey } from '../mapped/index.mjs';
|
|
22
22
|
import { type TNumber, type NumberOptions } from '../number/index.mjs';
|
|
23
23
|
import { type TObject, type TProperties, type ObjectOptions } from '../object/index.mjs';
|
|
24
|
-
import { type TOmit, type TOmitFromMappedKey } from '../omit/index.mjs';
|
|
24
|
+
import { type TOmit, type TOmitFromMappedKey, type TOmitFromMappedResult } from '../omit/index.mjs';
|
|
25
25
|
import { type TOptionalWithFlag, type TOptionalFromMappedResult } from '../optional/index.mjs';
|
|
26
26
|
import { type TPartial, type TPartialFromMappedResult } from '../partial/index.mjs';
|
|
27
|
-
import { type TPick, type TPickFromMappedKey } from '../pick/index.mjs';
|
|
27
|
+
import { type TPick, type TPickFromMappedKey, type TPickFromMappedResult } from '../pick/index.mjs';
|
|
28
28
|
import { type TReadonlyWithFlag, type TReadonlyFromMappedResult } from '../readonly/index.mjs';
|
|
29
29
|
import { type TReadonlyOptional } from '../readonly-optional/index.mjs';
|
|
30
30
|
import { type TRecordOrObject } from '../record/index.mjs';
|
|
@@ -127,6 +127,8 @@ export declare class JsonTypeBuilder {
|
|
|
127
127
|
/** `[Json]` Creates an Object type */
|
|
128
128
|
Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
129
129
|
/** `[Json]` Constructs a type whose keys are omitted from the given type */
|
|
130
|
+
Omit<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K], options?: SchemaOptions): TOmitFromMappedResult<T, K>;
|
|
131
|
+
/** `[Json]` Constructs a type whose keys are omitted from the given type */
|
|
130
132
|
Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K): TOmitFromMappedKey<T, K>;
|
|
131
133
|
/** `[Json]` Constructs a type whose keys are omitted from the given type */
|
|
132
134
|
Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TOmit<T, I>;
|
|
@@ -137,6 +139,8 @@ export declare class JsonTypeBuilder {
|
|
|
137
139
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
138
140
|
Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
|
|
139
141
|
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
142
|
+
Pick<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K]): TPickFromMappedResult<T, K>;
|
|
143
|
+
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
140
144
|
Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K): TPickFromMappedKey<T, K>;
|
|
141
145
|
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
142
146
|
Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
|
|
@@ -7,25 +7,14 @@ import { UnionCreate } from './union-create.mjs';
|
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// TypeGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
|
-
// prettier-ignore
|
|
11
10
|
import { IsOptional } from '../guard/type.mjs';
|
|
12
11
|
// prettier-ignore
|
|
13
12
|
function IsUnionOptional(T) {
|
|
14
|
-
|
|
15
|
-
return (T.length > 0
|
|
16
|
-
? IsOptional(L)
|
|
17
|
-
? true
|
|
18
|
-
: IsUnionOptional(R)
|
|
19
|
-
: false);
|
|
13
|
+
return T.some(L => IsOptional(L));
|
|
20
14
|
}
|
|
21
15
|
// prettier-ignore
|
|
22
|
-
function RemoveOptionalFromRest(T
|
|
23
|
-
|
|
24
|
-
return (T.length > 0
|
|
25
|
-
? IsOptional(L)
|
|
26
|
-
? RemoveOptionalFromRest(R, [...Acc, RemoveOptionalFromType(L)])
|
|
27
|
-
: RemoveOptionalFromRest(R, [...Acc, L])
|
|
28
|
-
: Acc);
|
|
16
|
+
function RemoveOptionalFromRest(T) {
|
|
17
|
+
return T.map(L => IsOptional(L) ? RemoveOptionalFromType(L) : L);
|
|
29
18
|
}
|
|
30
19
|
// prettier-ignore
|
|
31
20
|
function RemoveOptionalFromType(T) {
|
|
@@ -128,8 +128,8 @@ exports.ValueErrorIterator = ValueErrorIterator;
|
|
|
128
128
|
// --------------------------------------------------------------------------
|
|
129
129
|
// Create
|
|
130
130
|
// --------------------------------------------------------------------------
|
|
131
|
-
function Create(
|
|
132
|
-
return { type, schema, path, value, message: (0, function_1.GetErrorFunction)()(schema,
|
|
131
|
+
function Create(errorType, schema, path, value) {
|
|
132
|
+
return { type: errorType, schema, path, value, message: (0, function_1.GetErrorFunction)()({ errorType, path, schema, value }) };
|
|
133
133
|
}
|
|
134
134
|
// --------------------------------------------------------------------------
|
|
135
135
|
// Types
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { TSchema } from '../type/schema/index';
|
|
2
2
|
import { ValueErrorType } from './errors';
|
|
3
3
|
/** Creates an error message using en-US as the default locale */
|
|
4
|
-
export declare function DefaultErrorFunction(
|
|
5
|
-
export type
|
|
6
|
-
/**
|
|
4
|
+
export declare function DefaultErrorFunction(error: ErrorFunctionParameter): string;
|
|
5
|
+
export type ErrorFunctionParameter = {
|
|
6
|
+
/** The type of validation error */
|
|
7
|
+
errorType: ValueErrorType;
|
|
8
|
+
/** The path of the error */
|
|
9
|
+
path: string;
|
|
10
|
+
/** The schema associated with the error */
|
|
11
|
+
schema: TSchema;
|
|
12
|
+
/** The value associated with the error */
|
|
13
|
+
value: unknown;
|
|
14
|
+
};
|
|
15
|
+
export type ErrorFunction = (parameter: ErrorFunctionParameter) => string;
|
|
16
|
+
/** Sets the error function used to generate error messages. */
|
|
7
17
|
export declare function SetErrorFunction(callback: ErrorFunction): void;
|
|
8
18
|
/** Gets the error function used to generate error messages */
|
|
9
19
|
export declare function GetErrorFunction(): ErrorFunction;
|
|
@@ -5,18 +5,18 @@ exports.GetErrorFunction = exports.SetErrorFunction = exports.DefaultErrorFuncti
|
|
|
5
5
|
const index_1 = require("../type/symbols/index");
|
|
6
6
|
const errors_1 = require("./errors");
|
|
7
7
|
/** Creates an error message using en-US as the default locale */
|
|
8
|
-
function DefaultErrorFunction(
|
|
9
|
-
switch (errorType) {
|
|
8
|
+
function DefaultErrorFunction(error) {
|
|
9
|
+
switch (error.errorType) {
|
|
10
10
|
case errors_1.ValueErrorType.ArrayContains:
|
|
11
11
|
return 'Expected array to contain at least one matching value';
|
|
12
12
|
case errors_1.ValueErrorType.ArrayMaxContains:
|
|
13
|
-
return `Expected array to contain no more than ${schema.maxContains} matching values`;
|
|
13
|
+
return `Expected array to contain no more than ${error.schema.maxContains} matching values`;
|
|
14
14
|
case errors_1.ValueErrorType.ArrayMinContains:
|
|
15
|
-
return `Expected array to contain at least ${schema.minContains} matching values`;
|
|
15
|
+
return `Expected array to contain at least ${error.schema.minContains} matching values`;
|
|
16
16
|
case errors_1.ValueErrorType.ArrayMaxItems:
|
|
17
|
-
return `Expected array length to be less or equal to ${schema.maxItems}`;
|
|
17
|
+
return `Expected array length to be less or equal to ${error.schema.maxItems}`;
|
|
18
18
|
case errors_1.ValueErrorType.ArrayMinItems:
|
|
19
|
-
return `Expected array length to be greater or equal to ${schema.minItems}`;
|
|
19
|
+
return `Expected array length to be greater or equal to ${error.schema.minItems}`;
|
|
20
20
|
case errors_1.ValueErrorType.ArrayUniqueItems:
|
|
21
21
|
return 'Expected array elements to be unique';
|
|
22
22
|
case errors_1.ValueErrorType.Array:
|
|
@@ -24,43 +24,43 @@ function DefaultErrorFunction(schema, errorType) {
|
|
|
24
24
|
case errors_1.ValueErrorType.AsyncIterator:
|
|
25
25
|
return 'Expected AsyncIterator';
|
|
26
26
|
case errors_1.ValueErrorType.BigIntExclusiveMaximum:
|
|
27
|
-
return `Expected bigint to be less than ${schema.exclusiveMaximum}`;
|
|
27
|
+
return `Expected bigint to be less than ${error.schema.exclusiveMaximum}`;
|
|
28
28
|
case errors_1.ValueErrorType.BigIntExclusiveMinimum:
|
|
29
|
-
return `Expected bigint to be greater than ${schema.exclusiveMinimum}`;
|
|
29
|
+
return `Expected bigint to be greater than ${error.schema.exclusiveMinimum}`;
|
|
30
30
|
case errors_1.ValueErrorType.BigIntMaximum:
|
|
31
|
-
return `Expected bigint to be less or equal to ${schema.maximum}`;
|
|
31
|
+
return `Expected bigint to be less or equal to ${error.schema.maximum}`;
|
|
32
32
|
case errors_1.ValueErrorType.BigIntMinimum:
|
|
33
|
-
return `Expected bigint to be greater or equal to ${schema.minimum}`;
|
|
33
|
+
return `Expected bigint to be greater or equal to ${error.schema.minimum}`;
|
|
34
34
|
case errors_1.ValueErrorType.BigIntMultipleOf:
|
|
35
|
-
return `Expected bigint to be a multiple of ${schema.multipleOf}`;
|
|
35
|
+
return `Expected bigint to be a multiple of ${error.schema.multipleOf}`;
|
|
36
36
|
case errors_1.ValueErrorType.BigInt:
|
|
37
37
|
return 'Expected bigint';
|
|
38
38
|
case errors_1.ValueErrorType.Boolean:
|
|
39
39
|
return 'Expected boolean';
|
|
40
40
|
case errors_1.ValueErrorType.DateExclusiveMinimumTimestamp:
|
|
41
|
-
return `Expected Date timestamp to be greater than ${schema.exclusiveMinimumTimestamp}`;
|
|
41
|
+
return `Expected Date timestamp to be greater than ${error.schema.exclusiveMinimumTimestamp}`;
|
|
42
42
|
case errors_1.ValueErrorType.DateExclusiveMaximumTimestamp:
|
|
43
|
-
return `Expected Date timestamp to be less than ${schema.exclusiveMaximumTimestamp}`;
|
|
43
|
+
return `Expected Date timestamp to be less than ${error.schema.exclusiveMaximumTimestamp}`;
|
|
44
44
|
case errors_1.ValueErrorType.DateMinimumTimestamp:
|
|
45
|
-
return `Expected Date timestamp to be greater or equal to ${schema.minimumTimestamp}`;
|
|
45
|
+
return `Expected Date timestamp to be greater or equal to ${error.schema.minimumTimestamp}`;
|
|
46
46
|
case errors_1.ValueErrorType.DateMaximumTimestamp:
|
|
47
|
-
return `Expected Date timestamp to be less or equal to ${schema.maximumTimestamp}`;
|
|
47
|
+
return `Expected Date timestamp to be less or equal to ${error.schema.maximumTimestamp}`;
|
|
48
48
|
case errors_1.ValueErrorType.DateMultipleOfTimestamp:
|
|
49
|
-
return `Expected Date timestamp to be a multiple of ${schema.multipleOfTimestamp}`;
|
|
49
|
+
return `Expected Date timestamp to be a multiple of ${error.schema.multipleOfTimestamp}`;
|
|
50
50
|
case errors_1.ValueErrorType.Date:
|
|
51
51
|
return 'Expected Date';
|
|
52
52
|
case errors_1.ValueErrorType.Function:
|
|
53
53
|
return 'Expected function';
|
|
54
54
|
case errors_1.ValueErrorType.IntegerExclusiveMaximum:
|
|
55
|
-
return `Expected integer to be less than ${schema.exclusiveMaximum}`;
|
|
55
|
+
return `Expected integer to be less than ${error.schema.exclusiveMaximum}`;
|
|
56
56
|
case errors_1.ValueErrorType.IntegerExclusiveMinimum:
|
|
57
|
-
return `Expected integer to be greater than ${schema.exclusiveMinimum}`;
|
|
57
|
+
return `Expected integer to be greater than ${error.schema.exclusiveMinimum}`;
|
|
58
58
|
case errors_1.ValueErrorType.IntegerMaximum:
|
|
59
|
-
return `Expected integer to be less or equal to ${schema.maximum}`;
|
|
59
|
+
return `Expected integer to be less or equal to ${error.schema.maximum}`;
|
|
60
60
|
case errors_1.ValueErrorType.IntegerMinimum:
|
|
61
|
-
return `Expected integer to be greater or equal to ${schema.minimum}`;
|
|
61
|
+
return `Expected integer to be greater or equal to ${error.schema.minimum}`;
|
|
62
62
|
case errors_1.ValueErrorType.IntegerMultipleOf:
|
|
63
|
-
return `Expected integer to be a multiple of ${schema.multipleOf}`;
|
|
63
|
+
return `Expected integer to be a multiple of ${error.schema.multipleOf}`;
|
|
64
64
|
case errors_1.ValueErrorType.Integer:
|
|
65
65
|
return 'Expected integer';
|
|
66
66
|
case errors_1.ValueErrorType.IntersectUnevaluatedProperties:
|
|
@@ -70,7 +70,7 @@ function DefaultErrorFunction(schema, errorType) {
|
|
|
70
70
|
case errors_1.ValueErrorType.Iterator:
|
|
71
71
|
return 'Expected Iterator';
|
|
72
72
|
case errors_1.ValueErrorType.Literal:
|
|
73
|
-
return `Expected ${typeof schema.const === 'string' ? `'${schema.const}'` : schema.const}`;
|
|
73
|
+
return `Expected ${typeof error.schema.const === 'string' ? `'${error.schema.const}'` : error.schema.const}`;
|
|
74
74
|
case errors_1.ValueErrorType.Never:
|
|
75
75
|
return 'Never';
|
|
76
76
|
case errors_1.ValueErrorType.Not:
|
|
@@ -78,15 +78,15 @@ function DefaultErrorFunction(schema, errorType) {
|
|
|
78
78
|
case errors_1.ValueErrorType.Null:
|
|
79
79
|
return 'Expected null';
|
|
80
80
|
case errors_1.ValueErrorType.NumberExclusiveMaximum:
|
|
81
|
-
return `Expected number to be less than ${schema.exclusiveMaximum}`;
|
|
81
|
+
return `Expected number to be less than ${error.schema.exclusiveMaximum}`;
|
|
82
82
|
case errors_1.ValueErrorType.NumberExclusiveMinimum:
|
|
83
|
-
return `Expected number to be greater than ${schema.exclusiveMinimum}`;
|
|
83
|
+
return `Expected number to be greater than ${error.schema.exclusiveMinimum}`;
|
|
84
84
|
case errors_1.ValueErrorType.NumberMaximum:
|
|
85
|
-
return `Expected number to be less or equal to ${schema.maximum}`;
|
|
85
|
+
return `Expected number to be less or equal to ${error.schema.maximum}`;
|
|
86
86
|
case errors_1.ValueErrorType.NumberMinimum:
|
|
87
|
-
return `Expected number to be greater or equal to ${schema.minimum}`;
|
|
87
|
+
return `Expected number to be greater or equal to ${error.schema.minimum}`;
|
|
88
88
|
case errors_1.ValueErrorType.NumberMultipleOf:
|
|
89
|
-
return `Expected number to be a multiple of ${schema.multipleOf}`;
|
|
89
|
+
return `Expected number to be a multiple of ${error.schema.multipleOf}`;
|
|
90
90
|
case errors_1.ValueErrorType.Number:
|
|
91
91
|
return 'Expected number';
|
|
92
92
|
case errors_1.ValueErrorType.Object:
|
|
@@ -94,35 +94,35 @@ function DefaultErrorFunction(schema, errorType) {
|
|
|
94
94
|
case errors_1.ValueErrorType.ObjectAdditionalProperties:
|
|
95
95
|
return 'Unexpected property';
|
|
96
96
|
case errors_1.ValueErrorType.ObjectMaxProperties:
|
|
97
|
-
return `Expected object to have no more than ${schema.maxProperties} properties`;
|
|
97
|
+
return `Expected object to have no more than ${error.schema.maxProperties} properties`;
|
|
98
98
|
case errors_1.ValueErrorType.ObjectMinProperties:
|
|
99
|
-
return `Expected object to have at least ${schema.minProperties} properties`;
|
|
99
|
+
return `Expected object to have at least ${error.schema.minProperties} properties`;
|
|
100
100
|
case errors_1.ValueErrorType.ObjectRequiredProperty:
|
|
101
101
|
return 'Required property';
|
|
102
102
|
case errors_1.ValueErrorType.Promise:
|
|
103
103
|
return 'Expected Promise';
|
|
104
104
|
case errors_1.ValueErrorType.StringFormatUnknown:
|
|
105
|
-
return `Unknown format '${schema.format}'`;
|
|
105
|
+
return `Unknown format '${error.schema.format}'`;
|
|
106
106
|
case errors_1.ValueErrorType.StringFormat:
|
|
107
|
-
return `Expected string to match '${schema.format}' format`;
|
|
107
|
+
return `Expected string to match '${error.schema.format}' format`;
|
|
108
108
|
case errors_1.ValueErrorType.StringMaxLength:
|
|
109
|
-
return `Expected string length less or equal to ${schema.maxLength}`;
|
|
109
|
+
return `Expected string length less or equal to ${error.schema.maxLength}`;
|
|
110
110
|
case errors_1.ValueErrorType.StringMinLength:
|
|
111
|
-
return `Expected string length greater or equal to ${schema.minLength}`;
|
|
111
|
+
return `Expected string length greater or equal to ${error.schema.minLength}`;
|
|
112
112
|
case errors_1.ValueErrorType.StringPattern:
|
|
113
|
-
return `Expected string to match '${schema.pattern}'`;
|
|
113
|
+
return `Expected string to match '${error.schema.pattern}'`;
|
|
114
114
|
case errors_1.ValueErrorType.String:
|
|
115
115
|
return 'Expected string';
|
|
116
116
|
case errors_1.ValueErrorType.Symbol:
|
|
117
117
|
return 'Expected symbol';
|
|
118
118
|
case errors_1.ValueErrorType.TupleLength:
|
|
119
|
-
return `Expected tuple to have ${schema.maxItems || 0} elements`;
|
|
119
|
+
return `Expected tuple to have ${error.schema.maxItems || 0} elements`;
|
|
120
120
|
case errors_1.ValueErrorType.Tuple:
|
|
121
121
|
return 'Expected tuple';
|
|
122
122
|
case errors_1.ValueErrorType.Uint8ArrayMaxByteLength:
|
|
123
|
-
return `Expected byte length less or equal to ${schema.maxByteLength}`;
|
|
123
|
+
return `Expected byte length less or equal to ${error.schema.maxByteLength}`;
|
|
124
124
|
case errors_1.ValueErrorType.Uint8ArrayMinByteLength:
|
|
125
|
-
return `Expected byte length greater or equal to ${schema.minByteLength}`;
|
|
125
|
+
return `Expected byte length greater or equal to ${error.schema.minByteLength}`;
|
|
126
126
|
case errors_1.ValueErrorType.Uint8Array:
|
|
127
127
|
return 'Expected Uint8Array';
|
|
128
128
|
case errors_1.ValueErrorType.Undefined:
|
|
@@ -132,7 +132,7 @@ function DefaultErrorFunction(schema, errorType) {
|
|
|
132
132
|
case errors_1.ValueErrorType.Void:
|
|
133
133
|
return 'Expected void';
|
|
134
134
|
case errors_1.ValueErrorType.Kind:
|
|
135
|
-
return `Expected kind '${schema[index_1.Kind]}'`;
|
|
135
|
+
return `Expected kind '${error.schema[index_1.Kind]}'`;
|
|
136
136
|
default:
|
|
137
137
|
return 'Unknown error type';
|
|
138
138
|
}
|
|
@@ -140,7 +140,7 @@ function DefaultErrorFunction(schema, errorType) {
|
|
|
140
140
|
exports.DefaultErrorFunction = DefaultErrorFunction;
|
|
141
141
|
/** Manages error message providers */
|
|
142
142
|
let errorFunction = DefaultErrorFunction;
|
|
143
|
-
/** Sets the error function used to generate error messages */
|
|
143
|
+
/** Sets the error function used to generate error messages. */
|
|
144
144
|
function SetErrorFunction(callback) {
|
|
145
145
|
errorFunction = callback;
|
|
146
146
|
}
|
package/build/require/index.d.ts
CHANGED
|
@@ -36,11 +36,11 @@ export { Not, type TNot } from './type/not/index';
|
|
|
36
36
|
export { Null, type TNull } from './type/null/index';
|
|
37
37
|
export { Number, type TNumber, type NumberOptions } from './type/number/index';
|
|
38
38
|
export { Object, type TObject, type TProperties, type ObjectOptions } from './type/object/index';
|
|
39
|
-
export { Omit, type TOmit, type TOmitFromMappedKey } from './type/omit/index';
|
|
39
|
+
export { Omit, type TOmit, type TOmitFromMappedKey, type TOmitFromMappedResult } from './type/omit/index';
|
|
40
40
|
export { Optional, OptionalFromMappedResult, type TOptional, type TOptionalWithFlag, type TOptionalFromMappedResult } from './type/optional/index';
|
|
41
41
|
export { Parameters, type TParameters } from './type/parameters/index';
|
|
42
42
|
export { Partial, PartialFromMappedResult, type TPartial, type TPartialFromMappedResult } from './type/partial/index';
|
|
43
|
-
export { Pick, type TPick, type TPickFromMappedKey } from './type/pick/index';
|
|
43
|
+
export { Pick, type TPick, type TPickFromMappedKey, type TPickFromMappedResult } from './type/pick/index';
|
|
44
44
|
export { Promise, type TPromise } from './type/promise/index';
|
|
45
45
|
export { Readonly, ReadonlyFromMappedResult, type TReadonly, type TReadonlyWithFlag, type TReadonlyFromMappedResult } from './type/readonly/index';
|
|
46
46
|
export { ReadonlyOptional, type TReadonlyOptional } from './type/readonly-optional/index';
|
|
@@ -8,14 +8,10 @@ const type_1 = require("../clone/type");
|
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
9
|
// TypeGuard
|
|
10
10
|
// ------------------------------------------------------------------
|
|
11
|
-
// prettier-ignore
|
|
12
11
|
const type_2 = require("../guard/type");
|
|
13
12
|
// prettier-ignore
|
|
14
|
-
function FromRest(T
|
|
15
|
-
|
|
16
|
-
return (T.length > 0
|
|
17
|
-
? FromRest(R, [...Acc, FromSchema(L)])
|
|
18
|
-
: Acc);
|
|
13
|
+
function FromRest(T) {
|
|
14
|
+
return T.map(L => FromSchema(L));
|
|
19
15
|
}
|
|
20
16
|
// prettier-ignore
|
|
21
17
|
function FromIntersect(T) {
|
|
@@ -7,8 +7,7 @@ type TCompositeIndex<T extends TIntersect<TObject[]>, K extends string[], Acc ex
|
|
|
7
7
|
[_ in L]: TIndex<T, [L]>;
|
|
8
8
|
}> : Acc;
|
|
9
9
|
type TCompositeReduce<T extends TObject[]> = UnionToTuple<TCompositeKeys<T>> extends infer K ? Evaluate<TCompositeIndex<TIntersect<T>, Assert<K, string[]>>> : {};
|
|
10
|
-
|
|
11
|
-
export declare function CompositeResolve<T extends TObject[]>(T: [...T]): TCompositeResolve<T>;
|
|
10
|
+
type TCompositeResolve<T extends TObject[]> = TIntersect<T> extends TIntersect ? TObject<TCompositeReduce<T>> : TObject<{}>;
|
|
12
11
|
export type TComposite<T extends TObject[]> = TCompositeResolve<T>;
|
|
13
12
|
/** `[Json]` Creates a Composite object type */
|
|
14
13
|
export declare function Composite<T extends TObject[]>(T: [...T], options?: ObjectOptions): TComposite<T>;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Composite =
|
|
4
|
+
exports.Composite = void 0;
|
|
5
5
|
const index_1 = require("../object/index");
|
|
6
6
|
const index_2 = require("../intersect/index");
|
|
7
|
-
const index_3 = require("../
|
|
8
|
-
const index_4 = require("../
|
|
7
|
+
const index_3 = require("../indexed/index");
|
|
8
|
+
const index_4 = require("../keyof/index");
|
|
9
9
|
const type_1 = require("../clone/type");
|
|
10
10
|
function CompositeResolve(T) {
|
|
11
11
|
const intersect = (0, index_2.Intersect)(T, {});
|
|
12
|
-
const keys = (0,
|
|
13
|
-
const properties = keys.reduce((acc, key) => ({ ...acc, [key]: (0,
|
|
12
|
+
const keys = (0, index_4.KeyOfPropertyKeys)(intersect);
|
|
13
|
+
const properties = keys.reduce((acc, key) => ({ ...acc, [key]: (0, index_3.Index)(intersect, [key]) }), {});
|
|
14
14
|
return (0, index_1.Object)(properties);
|
|
15
15
|
}
|
|
16
|
-
exports.CompositeResolve = CompositeResolve;
|
|
17
16
|
/** `[Json]` Creates a Composite object type */
|
|
18
17
|
function Composite(T, options) {
|
|
19
18
|
return (0, type_1.CloneType)(CompositeResolve(T), options);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Const = void 0;
|
|
5
|
-
const value_1 = require("../guard/value");
|
|
6
5
|
const index_1 = require("../any/index");
|
|
7
6
|
const index_2 = require("../bigint/index");
|
|
8
7
|
const index_3 = require("../date/index");
|
|
@@ -17,12 +16,13 @@ const index_11 = require("../undefined/index");
|
|
|
17
16
|
const index_12 = require("../uint8array/index");
|
|
18
17
|
const index_13 = require("../unknown/index");
|
|
19
18
|
const index_14 = require("../clone/index");
|
|
19
|
+
// ------------------------------------------------------------------
|
|
20
|
+
// ValueGuard
|
|
21
|
+
// ------------------------------------------------------------------
|
|
22
|
+
const value_1 = require("../guard/value");
|
|
20
23
|
// prettier-ignore
|
|
21
24
|
function FromArray(T) {
|
|
22
|
-
|
|
23
|
-
return (T.length > 0
|
|
24
|
-
? [FromValue(L, false), ...FromArray(R)]
|
|
25
|
-
: []);
|
|
25
|
+
return T.map(L => FromValue(L, false));
|
|
26
26
|
}
|
|
27
27
|
// prettier-ignore
|
|
28
28
|
function FromProperties(value) {
|
|
@@ -37,7 +37,7 @@ function ConditionalReadonly(T, root) {
|
|
|
37
37
|
function FromValue(value, root) {
|
|
38
38
|
return ((0, value_1.IsAsyncIterator)(value) ? ConditionalReadonly((0, index_1.Any)(), root) :
|
|
39
39
|
(0, value_1.IsIterator)(value) ? ConditionalReadonly((0, index_1.Any)(), root) :
|
|
40
|
-
(0, value_1.IsArray)(value) ? (0, index_10.Readonly)((0, index_9.Tuple)(FromArray(value))) :
|
|
40
|
+
(0, value_1.IsArray)(value) ? (0, index_10.Readonly)((0, index_9.Tuple)(FromArray(value))) :
|
|
41
41
|
(0, value_1.IsUint8Array)(value) ? (0, index_12.Uint8Array)() :
|
|
42
42
|
(0, value_1.IsDate)(value) ? (0, index_3.Date)() :
|
|
43
43
|
(0, value_1.IsObject)(value) ? ConditionalReadonly((0, index_7.Object)(FromProperties(value)), root) :
|
|
@@ -4,7 +4,7 @@ import type { Ensure } from '../helpers/index';
|
|
|
4
4
|
import { Kind } from '../symbols/index';
|
|
5
5
|
type ConstructorStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
6
6
|
type ConstructorStaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? ConstructorStaticParameters<R, P, [...Acc, Static<L, P>]> : Acc;
|
|
7
|
-
|
|
7
|
+
type ConstructorStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<new (...param: ConstructorStaticParameters<T, P>) => ConstructorStaticReturnType<U, P>>);
|
|
8
8
|
export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
9
9
|
[Kind]: 'Constructor';
|
|
10
10
|
static: ConstructorStatic<T, U, this['params']>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Constructor = void 0;
|
|
5
|
-
const index_1 = require("../symbols/index");
|
|
6
5
|
const type_1 = require("../clone/type");
|
|
6
|
+
const index_1 = require("../symbols/index");
|
|
7
7
|
/** `[JavaScript]` Creates a Constructor type */
|
|
8
8
|
function Constructor(parameters, returns, options) {
|
|
9
9
|
return {
|
|
@@ -8,7 +8,6 @@ const value_1 = require("../guard/value");
|
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
9
|
// TypeGuard
|
|
10
10
|
// ------------------------------------------------------------------
|
|
11
|
-
// prettier-ignore
|
|
12
11
|
const type_2 = require("../guard/type");
|
|
13
12
|
function FromRest(schema, references) {
|
|
14
13
|
return schema.map((schema) => Deref(schema, references));
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Discard = void 0;
|
|
5
|
-
function
|
|
5
|
+
function DiscardKey(value, key) {
|
|
6
6
|
const { [key]: _, ...rest } = value;
|
|
7
7
|
return rest;
|
|
8
8
|
}
|
|
9
9
|
function Discard(value, keys) {
|
|
10
|
-
return keys.reduce((acc, key) =>
|
|
10
|
+
return keys.reduce((acc, key) => DiscardKey(acc, key), value);
|
|
11
11
|
}
|
|
12
12
|
exports.Discard = Discard;
|
|
@@ -5,6 +5,9 @@ exports.Enum = void 0;
|
|
|
5
5
|
const index_1 = require("../literal/index");
|
|
6
6
|
const index_2 = require("../symbols/index");
|
|
7
7
|
const index_3 = require("../union/index");
|
|
8
|
+
// ------------------------------------------------------------------
|
|
9
|
+
// ValueGuard
|
|
10
|
+
// ------------------------------------------------------------------
|
|
8
11
|
const value_1 = require("../guard/value");
|
|
9
12
|
/** `[Json]` Creates a Enum type */
|
|
10
13
|
function Enum(item, options = {}) {
|
|
@@ -2,10 +2,10 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TExclude } from './exclude';
|
|
5
|
-
type TFromProperties<K extends TProperties,
|
|
6
|
-
[K2 in keyof K]: TExclude<K[K2],
|
|
5
|
+
type TFromProperties<K extends TProperties, T extends TSchema> = ({
|
|
6
|
+
[K2 in keyof K]: TExclude<K[K2], T>;
|
|
7
7
|
});
|
|
8
|
-
type TFromMappedResult<
|
|
9
|
-
export type TExcludeFromMappedResult<
|
|
10
|
-
export declare function ExcludeFromMappedResult<
|
|
8
|
+
type TFromMappedResult<R extends TMappedResult, T extends TSchema> = (TFromProperties<R['properties'], T>);
|
|
9
|
+
export type TExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>> = (TMappedResult<P>);
|
|
10
|
+
export declare function ExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T, options: SchemaOptions): TMappedResult<P>;
|
|
11
11
|
export {};
|
|
@@ -5,18 +5,18 @@ exports.ExcludeFromMappedResult = void 0;
|
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const exclude_1 = require("./exclude");
|
|
7
7
|
// prettier-ignore
|
|
8
|
-
function FromProperties(
|
|
9
|
-
return globalThis.Object.getOwnPropertyNames(
|
|
10
|
-
return { ...Acc, [K2]: (0, exclude_1.Exclude)(
|
|
8
|
+
function FromProperties(P, U, options) {
|
|
9
|
+
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
|
|
10
|
+
return { ...Acc, [K2]: (0, exclude_1.Exclude)(P[K2], U, options) };
|
|
11
11
|
}, {});
|
|
12
12
|
}
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
function FromMappedResult(
|
|
15
|
-
return FromProperties(
|
|
14
|
+
function FromMappedResult(R, T, options) {
|
|
15
|
+
return FromProperties(R.properties, T, options);
|
|
16
16
|
}
|
|
17
17
|
// prettier-ignore
|
|
18
|
-
function ExcludeFromMappedResult(
|
|
19
|
-
const P = FromMappedResult(
|
|
18
|
+
function ExcludeFromMappedResult(R, T, options) {
|
|
19
|
+
const P = FromMappedResult(R, T, options);
|
|
20
20
|
return (0, index_1.MappedResult)(P);
|
|
21
21
|
}
|
|
22
22
|
exports.ExcludeFromMappedResult = ExcludeFromMappedResult;
|
|
@@ -11,7 +11,6 @@ const exclude_from_mapped_result_1 = require("./exclude-from-mapped-result");
|
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
12
|
// TypeGuard
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
|
-
// prettier-ignore
|
|
15
14
|
const type_2 = require("../guard/type");
|
|
16
15
|
// prettier-ignore
|
|
17
16
|
function ExcludeResolve(L, R) {
|
|
@@ -2,7 +2,7 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import type { Assert } from '../helpers/index';
|
|
4
4
|
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
5
|
-
import { TLiteral, TLiteralValue } from '../literal/index';
|
|
5
|
+
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
6
6
|
import { type TExtends } from './extends';
|
|
7
7
|
type TFromPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema> = {
|
|
8
8
|
[_ in K]: TExtends<TLiteral<Assert<K, TLiteralValue>>, U, L, R>;
|
|
@@ -12,11 +12,10 @@ function FromPropertyKey(K, U, L, R, options) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
// prettier-ignore
|
|
15
|
-
function FromPropertyKeys(K, U, L, R, options
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: Acc);
|
|
15
|
+
function FromPropertyKeys(K, U, L, R, options) {
|
|
16
|
+
return K.reduce((Acc, LK) => {
|
|
17
|
+
return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
|
|
18
|
+
}, {});
|
|
20
19
|
}
|
|
21
20
|
// prettier-ignore
|
|
22
21
|
function FromMappedKey(K, U, L, R, options) {
|
|
@@ -2,10 +2,10 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TExtends } from './extends';
|
|
5
|
-
type TFromProperties<
|
|
6
|
-
[K2 in keyof
|
|
5
|
+
type TFromProperties<P extends TProperties, Right extends TSchema, False extends TSchema, True extends TSchema> = ({
|
|
6
|
+
[K2 in keyof P]: TExtends<P[K2], Right, False, True>;
|
|
7
7
|
});
|
|
8
|
-
type TFromMappedResult<
|
|
9
|
-
export type TExtendsFromMappedResult<
|
|
10
|
-
export declare function ExtendsFromMappedResult<
|
|
8
|
+
type TFromMappedResult<Left extends TMappedResult, Right extends TSchema, True extends TSchema, False extends TSchema> = (TFromProperties<Left['properties'], Right, True, False>);
|
|
9
|
+
export type TExtendsFromMappedResult<Left extends TMappedResult, Right extends TSchema, True extends TSchema, False extends TSchema, P extends TProperties = TFromMappedResult<Left, Right, True, False>> = (TMappedResult<P>);
|
|
10
|
+
export declare function ExtendsFromMappedResult<Left extends TMappedResult, Right extends TSchema, True extends TSchema, False extends TSchema, P extends TProperties = TFromMappedResult<Left, Right, True, False>>(Left: Left, Right: Right, True: True, False: False, options: SchemaOptions): TMappedResult<P>;
|
|
11
11
|
export {};
|
|
@@ -5,18 +5,18 @@ exports.ExtendsFromMappedResult = void 0;
|
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const extends_1 = require("./extends");
|
|
7
7
|
// prettier-ignore
|
|
8
|
-
function FromProperties(
|
|
9
|
-
return globalThis.Object.getOwnPropertyNames(
|
|
10
|
-
return { ...Acc, [K2]: (0, extends_1.Extends)(
|
|
8
|
+
function FromProperties(P, Right, True, False, options) {
|
|
9
|
+
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
|
|
10
|
+
return { ...Acc, [K2]: (0, extends_1.Extends)(P[K2], Right, True, False, options) };
|
|
11
11
|
}, {});
|
|
12
12
|
}
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
function FromMappedResult(
|
|
15
|
-
return FromProperties(
|
|
14
|
+
function FromMappedResult(Left, Right, True, False, options) {
|
|
15
|
+
return FromProperties(Left.properties, Right, True, False, options);
|
|
16
16
|
}
|
|
17
17
|
// prettier-ignore
|
|
18
|
-
function ExtendsFromMappedResult(
|
|
19
|
-
const P = FromMappedResult(
|
|
18
|
+
function ExtendsFromMappedResult(Left, Right, True, False, options) {
|
|
19
|
+
const P = FromMappedResult(Left, Right, True, False, options);
|
|
20
20
|
return (0, index_1.MappedResult)(P);
|
|
21
21
|
}
|
|
22
22
|
exports.ExtendsFromMappedResult = ExtendsFromMappedResult;
|
|
@@ -10,7 +10,6 @@ const extends_from_mapped_result_1 = require("./extends-from-mapped-result");
|
|
|
10
10
|
// ------------------------------------------------------------------
|
|
11
11
|
// TypeGuard
|
|
12
12
|
// ------------------------------------------------------------------
|
|
13
|
-
// prettier-ignore
|
|
14
13
|
const type_2 = require("../guard/type");
|
|
15
14
|
// prettier-ignore
|
|
16
15
|
function ExtendsResolve(left, right, trueType, falseType) {
|
|
@@ -2,10 +2,10 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TExtract } from './extract';
|
|
5
|
-
type TFromProperties<
|
|
6
|
-
[K2 in keyof
|
|
5
|
+
type TFromProperties<P extends TProperties, T extends TSchema> = ({
|
|
6
|
+
[K2 in keyof P]: TExtract<P[K2], T>;
|
|
7
7
|
});
|
|
8
|
-
type TFromMappedResult<
|
|
9
|
-
export type TExtractFromMappedResult<
|
|
10
|
-
export declare function ExtractFromMappedResult<
|
|
8
|
+
type TFromMappedResult<R extends TMappedResult, T extends TSchema> = (TFromProperties<R['properties'], T>);
|
|
9
|
+
export type TExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>> = (TMappedResult<P>);
|
|
10
|
+
export declare function ExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T, options: SchemaOptions): TMappedResult<P>;
|
|
11
11
|
export {};
|