@candlerip/shared3 0.0.124 → 0.0.126
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -4,15 +4,21 @@ export const customErrorWorker = (info) => {
|
|
4
4
|
let _info = info;
|
5
5
|
let _projectName;
|
6
6
|
const addInfo = (info) => {
|
7
|
+
composeInfo(info);
|
8
|
+
};
|
9
|
+
const composeCustomError = (message, info) => {
|
10
|
+
composeInfo(info);
|
11
|
+
return composeCustomErrorFunc(message, _projectName ?? ProjectSingleton.getProjectName(), _info);
|
12
|
+
};
|
13
|
+
const composeInfo = (info) => {
|
14
|
+
if (!_info && !info) {
|
15
|
+
return;
|
16
|
+
}
|
7
17
|
_info = {
|
8
18
|
..._info,
|
9
19
|
...info,
|
10
20
|
};
|
11
21
|
};
|
12
|
-
const composeCustomError = (message, info) => composeCustomErrorFunc(message, _projectName ?? ProjectSingleton.getProjectName(), {
|
13
|
-
..._info,
|
14
|
-
...info,
|
15
|
-
});
|
16
22
|
const setProjectName = (projectName) => {
|
17
23
|
_projectName = projectName;
|
18
24
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { customErrorWorker } from '../../error/index.js';
|
2
2
|
import { isString } from './type-guard.js';
|
3
3
|
export const validateString = (data, name, regexp) => {
|
4
|
-
const { composeCustomError } = customErrorWorker({ data,
|
4
|
+
const { composeCustomError } = customErrorWorker({ data, ...(regexp && { regexp: regexp?.source }) });
|
5
5
|
if (!data) {
|
6
6
|
return {
|
7
7
|
customError: composeCustomError(`Missing ${name}`),
|