@leancodepl/validation 7.3.6 → 7.4.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/index.cjs.js +5 -2
- package/index.esm.d.ts +1 -0
- package/index.esm.js +5 -2
- package/package.json +5 -2
- package/src/lib/handleValidationErrors.d.ts +3 -3
package/index.cjs.js
CHANGED
|
@@ -21,7 +21,8 @@ function handleValidationErrors(validationErrors, errorCodesMap, validationResul
|
|
|
21
21
|
result
|
|
22
22
|
];
|
|
23
23
|
}
|
|
24
|
-
return handleValidationErrors(
|
|
24
|
+
return handleValidationErrors(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
validationErrors, errorCodesMap, nextResult);
|
|
25
26
|
};
|
|
26
27
|
const handleAll = (_validationErrorsToHandle, handler)=>{
|
|
27
28
|
let result = undefined;
|
|
@@ -51,7 +52,8 @@ function handleValidationErrors(validationErrors, errorCodesMap, validationResul
|
|
|
51
52
|
result
|
|
52
53
|
];
|
|
53
54
|
}
|
|
54
|
-
return handleValidationErrors(
|
|
55
|
+
return handleValidationErrors(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
validationErrors, errorCodesMap, nextResult);
|
|
55
57
|
};
|
|
56
58
|
return {
|
|
57
59
|
handle,
|
|
@@ -61,6 +63,7 @@ function handleValidationErrors(validationErrors, errorCodesMap, validationResul
|
|
|
61
63
|
return validationResults.reduce(reducer.reducer, reducer.initialValue);
|
|
62
64
|
}
|
|
63
65
|
return;
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
67
|
}
|
|
65
68
|
};
|
|
66
69
|
}
|
package/index.esm.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.esm.js
CHANGED
|
@@ -17,7 +17,8 @@ function handleValidationErrors(validationErrors, errorCodesMap, validationResul
|
|
|
17
17
|
result
|
|
18
18
|
];
|
|
19
19
|
}
|
|
20
|
-
return handleValidationErrors(
|
|
20
|
+
return handleValidationErrors(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
validationErrors, errorCodesMap, nextResult);
|
|
21
22
|
};
|
|
22
23
|
const handleAll = (_validationErrorsToHandle, handler)=>{
|
|
23
24
|
let result = undefined;
|
|
@@ -47,7 +48,8 @@ function handleValidationErrors(validationErrors, errorCodesMap, validationResul
|
|
|
47
48
|
result
|
|
48
49
|
];
|
|
49
50
|
}
|
|
50
|
-
return handleValidationErrors(
|
|
51
|
+
return handleValidationErrors(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
validationErrors, errorCodesMap, nextResult);
|
|
51
53
|
};
|
|
52
54
|
return {
|
|
53
55
|
handle,
|
|
@@ -57,6 +59,7 @@ function handleValidationErrors(validationErrors, errorCodesMap, validationResul
|
|
|
57
59
|
return validationResults.reduce(reducer.reducer, reducer.initialValue);
|
|
58
60
|
}
|
|
59
61
|
return;
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
63
|
}
|
|
61
64
|
};
|
|
62
65
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/validation",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@leancodepl/cqrs-client-base": "7.
|
|
6
|
+
"@leancodepl/cqrs-client-base": "7.4.0"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"sinon": "15.2.0"
|
|
7
10
|
},
|
|
8
11
|
"exports": {
|
|
9
12
|
"./package.json": "./package.json",
|
|
@@ -6,18 +6,18 @@ export type ReducerDescription<THandlerResult, TReturnValue = THandlerResult> =
|
|
|
6
6
|
export type SpecificValidationError<TErrors extends Record<string, number>, TError extends keyof TErrors> = ValidationError<Record<TError, TErrors[TError]>>;
|
|
7
7
|
export type ValidationErrorHandlerFunc<TErrorsToHandle extends Record<string, number>, THandledErrors extends keyof TErrorsToHandle, TResult> = (errorName: THandledErrors, error: SpecificValidationError<TErrorsToHandle, THandledErrors>) => TResult;
|
|
8
8
|
export type ValidationErrorsHandleFunc<TErrorsToHandle extends Record<string, number>, TInResult> = {
|
|
9
|
-
<THandledErrors extends keyof TErrorsToHandle, TResult>(validationErrors: THandledErrors | THandledErrors[], handler: ValidationErrorHandlerFunc<TErrorsToHandle, THandledErrors, TResult>): ValidationErrorsHandler<Omit<TErrorsToHandle, THandledErrors>,
|
|
9
|
+
<THandledErrors extends keyof TErrorsToHandle, TResult>(validationErrors: THandledErrors | THandledErrors[], handler: ValidationErrorHandlerFunc<TErrorsToHandle, THandledErrors, TResult>): ValidationErrorsHandler<Omit<TErrorsToHandle, THandledErrors>, TInResult | TResult>;
|
|
10
10
|
};
|
|
11
11
|
export type ValidationErrorHandlerAllFunc<TErrorsToHandle extends Record<string, number>, THandledErrors extends keyof TErrorsToHandle, TResult> = (errors: {
|
|
12
12
|
errorName: THandledErrors;
|
|
13
13
|
errors: SpecificValidationError<TErrorsToHandle, THandledErrors>[];
|
|
14
14
|
}[]) => TResult;
|
|
15
15
|
export type ValidationErrorsHandleAllFunc<TErrorsToHandle extends Record<string, number>, TInResult> = {
|
|
16
|
-
<THandledErrors extends keyof TErrorsToHandle, TResult>(validationErrors: THandledErrors | THandledErrors[], handler: ValidationErrorHandlerAllFunc<TErrorsToHandle, THandledErrors, TResult>): ValidationErrorsHandler<Omit<TErrorsToHandle, THandledErrors>,
|
|
16
|
+
<THandledErrors extends keyof TErrorsToHandle, TResult>(validationErrors: THandledErrors | THandledErrors[], handler: ValidationErrorHandlerAllFunc<TErrorsToHandle, THandledErrors, TResult>): ValidationErrorsHandler<Omit<TErrorsToHandle, THandledErrors>, TInResult | TResult>;
|
|
17
17
|
};
|
|
18
18
|
export interface ValidationErrorsHandler<TRemainingErrors extends Record<string, number>, TResult> {
|
|
19
19
|
handle: ValidationErrorsHandleFunc<TRemainingErrors, TResult>;
|
|
20
20
|
handleAll: ValidationErrorsHandleAllFunc<TRemainingErrors, TResult>;
|
|
21
|
-
check:
|
|
21
|
+
check: object extends TRemainingErrors ? <TReturnValue = void>(reducer?: ReducerDescription<TResult, TReturnValue>) => TReturnValue : unknown;
|
|
22
22
|
}
|
|
23
23
|
export declare function handleValidationErrors<TAllErrors extends Record<string, number>, TInResult = never>(validationErrors: ValidationError<TAllErrors>[], errorCodesMap: TAllErrors, validationResults?: TInResult[]): ValidationErrorsHandler<TAllErrors, TInResult>;
|