@nu-art/ts-common 0.203.43 → 0.203.45
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/core/exceptions/http-codes.d.ts +3 -0
- package/core/exceptions/http-codes.js +1 -0
- package/core/exceptions/types.d.ts +1 -1
- package/core/module-manager.d.ts +12 -12
- package/db/types.d.ts +3 -3
- package/package.json +1 -1
- package/tools/Replacer.js +1 -2
- package/utils/array-tools.d.ts +11 -11
- package/utils/object-tools.d.ts +2 -2
- package/utils/tools.d.ts +4 -4
- package/utils/tools.js +3 -1
- package/utils/types.d.ts +2 -2
- package/validator/type-validators.d.ts +8 -8
- package/validator/validator-core.d.ts +9 -10
- package/validator/validator-core.js +4 -5
|
@@ -123,6 +123,9 @@ export declare const HttpCodes: {
|
|
|
123
123
|
readonly ENTITY_IS_OUTDATED: ((userMessage: string, debugMessage?: string, cause?: Error) => ApiException<ApiError_GeneralErrorMessage>) & {
|
|
124
124
|
code: number;
|
|
125
125
|
};
|
|
126
|
+
readonly INTERNAL_MISMATCH: ((userMessage: string, debugMessage?: string, cause?: Error) => ApiException<ApiError_GeneralErrorMessage>) & {
|
|
127
|
+
code: number;
|
|
128
|
+
};
|
|
126
129
|
readonly OPERATION_FAILED: ((userMessage: string, debugMessage?: string, cause?: Error) => ApiException<ApiError_GeneralErrorMessage>) & {
|
|
127
130
|
code: number;
|
|
128
131
|
};
|
package/core/module-manager.d.ts
CHANGED
|
@@ -5,23 +5,23 @@ import { Module } from './module';
|
|
|
5
5
|
import { Logger } from './logger/Logger';
|
|
6
6
|
export declare function moduleResolver(): Module<any, any, import("..").Validator<any> | import("..").TypeValidator<any>>[];
|
|
7
7
|
export declare const RuntimeModules: () => {
|
|
8
|
-
filter: <T
|
|
9
|
-
find: <T_1
|
|
10
|
-
some: <T_2
|
|
11
|
-
map: <T_3
|
|
12
|
-
forEach: <T_4
|
|
13
|
-
includes: <T_5
|
|
8
|
+
filter: <T>(filter: (item: T, index: number, array: T[]) => boolean) => T[];
|
|
9
|
+
find: <T_1>(filter: (item: T_1, index: number, array: T_1[]) => boolean) => T_1;
|
|
10
|
+
some: <T_2>(filter: (item: T_2, index: number, array: T_2[]) => boolean) => T_2;
|
|
11
|
+
map: <T_3, S>(processor: (item: T_3, index: number, array: T_3[]) => S) => S[];
|
|
12
|
+
forEach: <T_4>(processor: (item: T_4, index: number, array: T_4[]) => void) => void;
|
|
13
|
+
includes: <T_5>(module: T_5) => boolean;
|
|
14
14
|
all: Module<any, any, import("..").Validator<any> | import("..").TypeValidator<any>>[];
|
|
15
15
|
};
|
|
16
16
|
export declare class ModuleManager extends Logger {
|
|
17
17
|
protected config: any;
|
|
18
18
|
readonly modules: {
|
|
19
|
-
filter: <T
|
|
20
|
-
find: <T_1
|
|
21
|
-
some: <T_2
|
|
22
|
-
map: <T_3
|
|
23
|
-
forEach: <T_4
|
|
24
|
-
includes: <T_5
|
|
19
|
+
filter: <T>(filter: (item: T, index: number, array: T[]) => boolean) => T[];
|
|
20
|
+
find: <T_1>(filter: (item: T_1, index: number, array: T_1[]) => boolean) => T_1;
|
|
21
|
+
some: <T_2>(filter: (item: T_2, index: number, array: T_2[]) => boolean) => T_2;
|
|
22
|
+
map: <T_3, S>(processor: (item: T_3, index: number, array: T_3[]) => S) => S[];
|
|
23
|
+
forEach: <T_4>(processor: (item: T_4, index: number, array: T_4[]) => void) => void;
|
|
24
|
+
includes: <T_5>(module: T_5) => boolean;
|
|
25
25
|
all: Module<any, any, import("..").Validator<any> | import("..").TypeValidator<any>>[];
|
|
26
26
|
};
|
|
27
27
|
static instance: ModuleManager;
|
package/db/types.d.ts
CHANGED
|
@@ -113,15 +113,15 @@ export type MetadataProperty<ValueType> = {
|
|
|
113
113
|
optional: boolean;
|
|
114
114
|
description: string;
|
|
115
115
|
};
|
|
116
|
-
export type MetadataObject<T
|
|
116
|
+
export type MetadataObject<T> = {
|
|
117
117
|
[K in keyof T]-?: MetadataNested<T[K]>;
|
|
118
118
|
};
|
|
119
|
-
export type MetadataNested<T
|
|
119
|
+
export type MetadataNested<T> = T extends (infer I)[] ? MetadataProperty<T> & {
|
|
120
120
|
metadata: Metadata<I>;
|
|
121
121
|
} : T extends object ? MetadataProperty<T> & {
|
|
122
122
|
metadata: MetadataObject<T>;
|
|
123
123
|
} : MetadataProperty<T>;
|
|
124
|
-
export type Metadata<T
|
|
124
|
+
export type Metadata<T> = T extends (infer I)[] ? MetadataProperty<T> & {
|
|
125
125
|
metadata: Metadata<I>;
|
|
126
126
|
} : T extends object ? MetadataObject<T> : MetadataProperty<T>;
|
|
127
127
|
export {};
|
package/package.json
CHANGED
package/tools/Replacer.js
CHANGED
|
@@ -53,10 +53,9 @@ class Replacer extends Logger_1.Logger {
|
|
|
53
53
|
replaceParams(content = '', runtime) {
|
|
54
54
|
const matches = content.match(Replacer.Regexp_paramGroup);
|
|
55
55
|
return (matches === null || matches === void 0 ? void 0 : matches.reduce((toRet, match) => {
|
|
56
|
-
var _a;
|
|
57
56
|
let param = match;
|
|
58
57
|
while (Replacer.Regexp_param.test(param))
|
|
59
|
-
param =
|
|
58
|
+
param = param.match(Replacer.Regexp_param)[1];
|
|
60
59
|
if (param === undefined)
|
|
61
60
|
return toRet;
|
|
62
61
|
const value = this.resolveParam(param, toRet, runtime);
|
package/utils/array-tools.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export declare function sortArray<T>(array: T[], map?: keyof T | (keyof T)[] | (
|
|
|
74
74
|
/**
|
|
75
75
|
* "splits" array into given size of chunks and then does "action" on chunk and return to array of actions on chunks +-
|
|
76
76
|
* */
|
|
77
|
-
export declare function batchAction<T
|
|
77
|
+
export declare function batchAction<T = any, R = any>(arr: T[], chunk: number, action: (elements: T[]) => Promise<R | R[]>): Promise<R[]>;
|
|
78
78
|
/**
|
|
79
79
|
* Processes an array of promise-returning tasks sequentially.
|
|
80
80
|
*
|
|
@@ -94,7 +94,7 @@ export declare function batchAction<T extends any = any, R extends any = any>(ar
|
|
|
94
94
|
* @param promises
|
|
95
95
|
*/
|
|
96
96
|
export declare function Promise_all_sequentially<T>(promises: Array<() => Promise<T>>): Promise<T[]>;
|
|
97
|
-
export declare function batchActionParallel<T
|
|
97
|
+
export declare function batchActionParallel<T = any, R = any>(arr: T[], chunk: number, action: (elements: T[]) => Promise<R | R[]>): Promise<R[]>;
|
|
98
98
|
/**
|
|
99
99
|
* Returns a flat array from an array of arrays.
|
|
100
100
|
* @param arr An array that is potentially a matrix
|
|
@@ -102,21 +102,21 @@ export declare function batchActionParallel<T extends any = any, R extends any =
|
|
|
102
102
|
*/
|
|
103
103
|
export declare function flatArray<T extends any[], K = NestedArrayType<T>>(arr: T, result?: K[]): K[];
|
|
104
104
|
export declare function filterFlatInstances<T extends any[], K = NestedArrayType<T>>(arr: T, result?: K[]): Exclude<K, undefined>[];
|
|
105
|
-
export declare function groupArrayBy<T
|
|
105
|
+
export declare function groupArrayBy<T, K extends string | number>(arr: T[], mapper: (item: T, index: number) => K): {
|
|
106
106
|
key: K;
|
|
107
107
|
values: T[];
|
|
108
108
|
}[];
|
|
109
|
-
export declare function toggleInArray<T
|
|
110
|
-
export declare function generateArray<T
|
|
111
|
-
export declare function asArray<T
|
|
112
|
-
export declare function asOptionalArray<T
|
|
113
|
-
export declare function lastElement<T
|
|
114
|
-
export declare function firstElement<T
|
|
115
|
-
export declare function arrayIncludesAny<T
|
|
109
|
+
export declare function toggleInArray<T = string, K = (T extends object ? keyof T : T)>(arr: T[], item: T, mapper?: (item: T) => K): void;
|
|
110
|
+
export declare function generateArray<T = number>(length: number, mapper?: (index: number) => T): T[];
|
|
111
|
+
export declare function asArray<T>(toBeArray: T | T[]): T[];
|
|
112
|
+
export declare function asOptionalArray<T>(toBeArray?: T | T[]): T[] | undefined;
|
|
113
|
+
export declare function lastElement<T>(array: T[] | undefined): T | undefined;
|
|
114
|
+
export declare function firstElement<T>(array?: T[]): T | undefined;
|
|
115
|
+
export declare function arrayIncludesAny<T>(arr1: T[], arr2: T[]): boolean;
|
|
116
116
|
/**
|
|
117
117
|
* Returns true if arr1 returns the entirety of arr2
|
|
118
118
|
* @param arr1
|
|
119
119
|
* @param arr2
|
|
120
120
|
*/
|
|
121
|
-
export declare function arrayIncludesAll<T
|
|
121
|
+
export declare function arrayIncludesAll<T>(arr1: T[], arr2: T[]): boolean;
|
|
122
122
|
export {};
|
package/utils/object-tools.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ export declare function _values<T extends TS_Object = TS_Object>(object: T): (T[
|
|
|
7
7
|
export declare function _setTypedProp<T extends TS_Object>(instance: T, key: keyof T, value: T[keyof T]): void;
|
|
8
8
|
export declare function cloneArr<T>(value: T[]): T[];
|
|
9
9
|
export declare function cloneObj<T extends TS_Object>(obj: T): T;
|
|
10
|
-
export declare function partialCompare<T
|
|
10
|
+
export declare function partialCompare<T>(one?: T, two?: T, keysToFilterOut?: (keyof T)[]): boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Returns true for equal.
|
|
13
13
|
*/
|
|
14
|
-
export declare function compare<T
|
|
14
|
+
export declare function compare<T>(one?: T, two?: T, keys?: (keyof T)[]): boolean;
|
|
15
15
|
export declare function assert<T>(message: string, expected: T, actual: T): void;
|
|
16
16
|
export declare function filterKeys<T extends TS_Object = TS_Object>(obj: T, keys?: keyof T | (keyof T)[], filter?: (k: keyof T, obj: T) => boolean): T;
|
package/utils/tools.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ export declare const EmptyArray: readonly never[];
|
|
|
10
10
|
export declare const voidFunction: () => Promise<void>;
|
|
11
11
|
export declare const functionThatReturnsFalse: () => false;
|
|
12
12
|
export declare const functionThatReturnsTrue: () => true;
|
|
13
|
-
export declare const resolveContent: <T
|
|
14
|
-
export declare const resolveFunctionOrValue: <T
|
|
15
|
-
export declare function exists<T
|
|
16
|
-
export declare function freeze<T
|
|
13
|
+
export declare const resolveContent: <T = any, P extends any[] = any[]>(content: ResolvableContent<T, P>, ...param: P) => T;
|
|
14
|
+
export declare const resolveFunctionOrValue: <T = any, P extends any[] = any[]>(content: ResolvableContent<T, P>, ...param: P) => T;
|
|
15
|
+
export declare function exists<T = any>(item: T | undefined | null): item is T;
|
|
16
|
+
export declare function freeze<T = any>(item: T): Readonly<T>;
|
|
17
17
|
export declare const logicalXOR: (a: boolean, b: boolean) => boolean;
|
|
18
18
|
export type KeyBinder<K extends string, Type> = {
|
|
19
19
|
Key: K;
|
package/utils/tools.js
CHANGED
|
@@ -66,7 +66,9 @@ exports.voidFunction = Object.freeze(() => __awaiter(void 0, void 0, void 0, fun
|
|
|
66
66
|
}));
|
|
67
67
|
exports.functionThatReturnsFalse = Object.freeze(() => false);
|
|
68
68
|
exports.functionThatReturnsTrue = Object.freeze(() => true);
|
|
69
|
-
const resolveContent = (content, ...param) =>
|
|
69
|
+
const resolveContent = (content, ...param) => {
|
|
70
|
+
return typeof content === 'function' ? content(...param) : content;
|
|
71
|
+
};
|
|
70
72
|
exports.resolveContent = resolveContent;
|
|
71
73
|
exports.resolveFunctionOrValue = exports.resolveContent;
|
|
72
74
|
function exists(item) {
|
package/utils/types.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export type SubsetObjectByValue<T, ExpectedType> = SubsetObjectByKeys<T, SubsetK
|
|
|
52
52
|
export type OptionalKeys<T extends TS_Object> = Exclude<{
|
|
53
53
|
[K in keyof T]: T extends Record<K, T[K]> ? never : K;
|
|
54
54
|
}[keyof T], undefined>;
|
|
55
|
-
export type MandatoryKeys<T extends TS_Object, V
|
|
55
|
+
export type MandatoryKeys<T extends TS_Object, V = any> = Exclude<{
|
|
56
56
|
[K in keyof T]: T extends Record<K, T[K]> ? (T[K] extends V ? K : never) : never;
|
|
57
57
|
}[keyof T], undefined>;
|
|
58
58
|
export type RequireOptionals<T extends TS_Object, Keys extends OptionalKeys<T> = OptionalKeys<T>> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
@@ -68,7 +68,7 @@ export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<
|
|
|
68
68
|
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
|
|
69
69
|
}[Keys];
|
|
70
70
|
export type Constructor<T> = new (...args: any) => T;
|
|
71
|
-
export type ArrayType<T
|
|
71
|
+
export type ArrayType<T> = T extends (infer I)[] ? I : never;
|
|
72
72
|
export type NestedArrayType<T extends any[]> = T extends (infer I)[] ? I extends any[] ? NestedArrayType<I> : I : never;
|
|
73
73
|
export type PartialProperties<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
74
74
|
export type KeyValue = TypedKeyValue<string, string>;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { InvalidResult, InvalidResultObject, Validator, ValidatorTypeResolver } from './validator-core';
|
|
2
2
|
import { ArrayType, AuditBy, RangeTimestamp, TypedMap } from '../utils/types';
|
|
3
3
|
export declare const tsValidateDynamicObject: <T extends object>(valuesValidator: ValidatorTypeResolver<T[keyof T]>, keysValidator: ValidatorTypeResolver<string>, mandatory?: boolean) => (import("./validator-core").ValidatorImpl<any> | ((input?: T | undefined) => InvalidResultObject<T> | undefined))[];
|
|
4
|
-
export declare const tsValidateUnion: <T
|
|
5
|
-
export declare const tsValidateCustom: <T
|
|
4
|
+
export declare const tsValidateUnion: <T>(validators: ValidatorTypeResolver<T>[], mandatory?: boolean) => import("./validator-core").ValidatorImpl<any>[];
|
|
5
|
+
export declare const tsValidateCustom: <T>(processor: (input?: T | undefined, parentInput?: any) => InvalidResult<T>, mandatory?: boolean) => Validator<T>[];
|
|
6
6
|
declare const typeFunc: (type: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
7
7
|
type types = ReturnType<typeof typeFunc>;
|
|
8
8
|
type validatorObject<T> = {
|
|
9
9
|
[k in types]?: ValidatorTypeResolver<T>;
|
|
10
10
|
};
|
|
11
|
-
export declare const tsValidateUnionV3: <T
|
|
11
|
+
export declare const tsValidateUnionV3: <T>(validatorObject: validatorObject<T>, mandatory?: boolean) => (import("./validator-core").ValidatorImpl<any> | ((input?: T | undefined) => "Input does not match any of the possible types" | InvalidResult<T> | undefined))[];
|
|
12
12
|
export declare const tsValidateArray: <T extends any[], I extends ArrayType<T> = ArrayType<T>>(validator: ValidatorTypeResolver<I> | ValidatorTypeResolver<I>[], mandatory?: boolean, minimumLength?: number) => Validator<I[]>;
|
|
13
13
|
export declare const tsValidateString: (length?: number | [number, number], mandatory?: boolean) => Validator<string>;
|
|
14
14
|
export declare const tsValidateStringMinLength: (length: number, mandatory?: boolean) => Validator<string>;
|
|
15
15
|
export declare const tsValidateNumber: (mandatory?: boolean) => Validator<number>;
|
|
16
16
|
export declare const tsValidateEnum: (enumType: TypedMap<number | string>, mandatory?: boolean) => Validator<number | string>;
|
|
17
17
|
export declare const tsValidateBoolean: (mandatory?: boolean) => Validator<boolean>;
|
|
18
|
-
export declare const tsValidateValue: <T>(values: T[], mandatory?: boolean) => Validator<any>;
|
|
18
|
+
export declare const tsValidateValue: <T>(values: readonly T[] | T[], mandatory?: boolean) => Validator<any>;
|
|
19
19
|
export declare const tsValidateIsInRange: (ranges: [number, number][], mandatory?: boolean) => Validator<number>;
|
|
20
20
|
export declare const tsValidateRange: (mandatory?: boolean) => Validator<[number, number] | undefined>;
|
|
21
21
|
export declare const tsValidateRegexp: (regexp: RegExp, mandatory?: boolean) => Validator<string>;
|
|
22
22
|
export declare const tsValidateTimestamp: (interval?: number, mandatory?: boolean) => Validator<number>;
|
|
23
|
-
export declare const tsValidateAudit: (range?: RangeTimestamp) => (audit?: AuditBy) =>
|
|
24
|
-
export declare const tsValidateNonMandatoryObject: <T extends object>(validator: ValidatorTypeResolver<T>) => ((input?: T | undefined) =>
|
|
25
|
-
export declare const tsValidateOptionalObject: <T extends object>(validator: ValidatorTypeResolver<T>) => ((input?: T | undefined) =>
|
|
26
|
-
export declare const tsValidator_valueByKey: <T
|
|
23
|
+
export declare const tsValidateAudit: (range?: RangeTimestamp) => (audit?: AuditBy) => string | undefined;
|
|
24
|
+
export declare const tsValidateNonMandatoryObject: <T extends object | undefined>(validator: ValidatorTypeResolver<T>) => (import("./validator-core").ValidatorImpl<any> | ((input?: T | undefined) => InvalidResult<T> | undefined))[];
|
|
25
|
+
export declare const tsValidateOptionalObject: <T extends object | undefined>(validator: ValidatorTypeResolver<T>) => (import("./validator-core").ValidatorImpl<any> | ((input?: T | undefined) => InvalidResult<T> | undefined))[];
|
|
26
|
+
export declare const tsValidator_valueByKey: <T>(validatorObject: {
|
|
27
27
|
[k: string]: Validator<any> | import("./validator-core").TypeValidator<any>;
|
|
28
28
|
}, prop?: string) => ValidatorTypeResolver<T>;
|
|
29
29
|
export declare const tsValidator_ArrayOfObjectsByKey: <T extends Object>(key: keyof T, validatorMap: {
|
|
@@ -8,24 +8,23 @@ import { CustomException } from '../core/exceptions/exceptions';
|
|
|
8
8
|
* K extends [infer E1, infer E2, infer E3] ? [Validator<E1>,Validator<E2>,Validator<E2>] :
|
|
9
9
|
* K extends [infer E1, infer E2, infer E3, infer E4] ? [Validator<E1>,Validator<E2>,Validator<E2>,Validator<E4>] :
|
|
10
10
|
*/
|
|
11
|
-
export type ValidatorTypeResolver<K> = K extends [
|
|
12
|
-
export type ValidatorImpl<P> = (p?: P) => (InvalidResult<P> | undefined);
|
|
11
|
+
export type ValidatorTypeResolver<K> = K extends [any] ? Validator<K> : K extends [any, any] ? Validator<K> : K extends [any, any, any] ? Validator<K> : K extends [any, any, any, any] ? Validator<K> : K extends any[] ? Validator<K> : K extends TS_Object ? TypeValidator<K> | Validator<K> : Validator<K>;
|
|
12
|
+
export type ValidatorImpl<P> = (p?: P, parentObj?: any) => (InvalidResult<P> | undefined);
|
|
13
13
|
export type Validator<P> = ValidatorImpl<P> | ValidatorImpl<P>[];
|
|
14
14
|
export type TypeValidator<T extends TS_Object> = {
|
|
15
15
|
[P in keyof T]-?: ValidatorTypeResolver<T[P]>;
|
|
16
16
|
};
|
|
17
|
-
export type InvalidResultObject<T
|
|
17
|
+
export type InvalidResultObject<T> = {
|
|
18
18
|
[K in keyof T]?: InvalidResult<T[K]>;
|
|
19
19
|
};
|
|
20
|
-
export type InvalidResultArray<T
|
|
21
|
-
export type InvalidResult<T
|
|
22
|
-
export declare class ValidationException<T
|
|
20
|
+
export type InvalidResultArray<T> = InvalidResult<T> | undefined;
|
|
21
|
+
export type InvalidResult<T> = T extends object ? InvalidResultObject<T> | string | undefined : T extends (infer I)[] ? (InvalidResultArray<I>[]) | string | undefined : string | undefined;
|
|
22
|
+
export declare class ValidationException<T> extends CustomException {
|
|
23
23
|
input?: T;
|
|
24
24
|
result?: InvalidResult<T>;
|
|
25
25
|
constructor(debugMessage: string, input?: T, result?: InvalidResult<T>, e?: Error);
|
|
26
26
|
}
|
|
27
|
-
export declare const assertValidateMandatoryProperty: (mandatory: boolean, input?: any) => void;
|
|
28
27
|
export declare const tsValidateExists: (mandatory?: boolean) => ValidatorImpl<any>;
|
|
29
|
-
export declare const tsValidate: <T
|
|
30
|
-
export declare const tsValidateResult: <T
|
|
31
|
-
export declare const tsValidateObject: <T>(__validator: TypeValidator<
|
|
28
|
+
export declare const tsValidate: <T>(instance: T | undefined, _validator: ValidatorTypeResolver<T>, strict?: boolean) => InvalidResult<T> | undefined;
|
|
29
|
+
export declare const tsValidateResult: <T>(instance: T | undefined, _validator: ValidatorTypeResolver<T>, key?: keyof T | undefined, parentInstance?: any) => InvalidResult<T> | undefined;
|
|
30
|
+
export declare const tsValidateObject: <T extends object>(__validator: TypeValidator<T>, instance: T, path?: string) => InvalidResultObject<T> | undefined;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.tsValidateObject = exports.tsValidateResult = exports.tsValidate = exports.tsValidateExists = exports.
|
|
20
|
+
exports.tsValidateObject = exports.tsValidateResult = exports.tsValidate = exports.tsValidateExists = exports.ValidationException = void 0;
|
|
21
21
|
const object_tools_1 = require("../utils/object-tools");
|
|
22
22
|
const exceptions_1 = require("../core/exceptions/exceptions");
|
|
23
23
|
class ValidationException extends exceptions_1.CustomException {
|
|
@@ -29,9 +29,6 @@ class ValidationException extends exceptions_1.CustomException {
|
|
|
29
29
|
}
|
|
30
30
|
exports.ValidationException = ValidationException;
|
|
31
31
|
const CONST_NO_ERROR = '###';
|
|
32
|
-
const assertValidateMandatoryProperty = (mandatory, input) => {
|
|
33
|
-
};
|
|
34
|
-
exports.assertValidateMandatoryProperty = assertValidateMandatoryProperty;
|
|
35
32
|
const tsValidateExists = (mandatory = true) => {
|
|
36
33
|
return (input) => {
|
|
37
34
|
if (input !== undefined && input !== null)
|
|
@@ -74,7 +71,9 @@ const tsValidateResult = (instance, _validator, key, parentInstance) => {
|
|
|
74
71
|
return 'No validator provided!';
|
|
75
72
|
const validator = typeof _validator === 'function' ? [_validator] : _validator;
|
|
76
73
|
if (Array.isArray(validator)) {
|
|
77
|
-
const result = validator.reduce((result, __validator) =>
|
|
74
|
+
const result = validator.reduce((result, __validator) => {
|
|
75
|
+
return result === CONST_NO_ERROR ? result : result || __validator(instance, parentInstance);
|
|
76
|
+
}, undefined);
|
|
78
77
|
return result !== CONST_NO_ERROR ? result : undefined;
|
|
79
78
|
}
|
|
80
79
|
if (typeof validator === 'object') {
|