@tsed/schema 7.69.4 → 7.70.1
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/lib/browser/schema.umd.min.js +1 -1
- package/lib/browser/schema.umd.min.js.map +1 -1
- package/lib/cjs/utils/withErrorMsg.js +18 -2
- package/lib/cjs/utils/withErrorMsg.js.map +1 -1
- package/lib/esm/utils/withErrorMsg.js +19 -3
- package/lib/esm/utils/withErrorMsg.js.map +1 -1
- package/package.json +7 -7
|
@@ -2,14 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withErrorMsg = void 0;
|
|
4
4
|
const core_1 = require("@tsed/core");
|
|
5
|
-
const
|
|
5
|
+
const jsonEntityFn_1 = require("../decorators/common/jsonEntityFn");
|
|
6
6
|
function withErrorMsg(errorKey, originalDecorator) {
|
|
7
7
|
const schema = {};
|
|
8
8
|
return ((...decoratorOptions) => {
|
|
9
9
|
const decorator = (0, core_1.useDecorators)(originalDecorator(...decoratorOptions));
|
|
10
10
|
decorator.Error = (message) => {
|
|
11
11
|
schema.message = message;
|
|
12
|
-
return (0, core_1.useDecorators)(decorator, schema.message &&
|
|
12
|
+
return (0, core_1.useDecorators)(decorator, schema.message &&
|
|
13
|
+
(0, jsonEntityFn_1.JsonEntityFn)((store) => {
|
|
14
|
+
// since errorMessage is a custom key, it is prefixed with a # to avoid conflict with JSON Schema keywords
|
|
15
|
+
const errorMessage = store.parentSchema.get("#errorMessage") || {};
|
|
16
|
+
if (errorKey === "required") {
|
|
17
|
+
store.parentSchema.customKey("errorMessage", (0, core_1.deepMerge)(errorMessage, {
|
|
18
|
+
[errorKey]: {
|
|
19
|
+
[store.propertyName]: message
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
store.itemSchema.customKey("errorMessage", (0, core_1.deepMerge)(errorMessage, {
|
|
25
|
+
[errorKey]: message
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
13
29
|
};
|
|
14
30
|
return decorator;
|
|
15
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withErrorMsg.js","sourceRoot":"","sources":["../../../src/utils/withErrorMsg.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"withErrorMsg.js","sourceRoot":"","sources":["../../../src/utils/withErrorMsg.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AACpD,oEAA+D;AAY/D,SAAgB,YAAY,CAC1B,QAAgB,EAChB,iBAA4B;IAE5B,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,OAAO,CAAC,CAAC,GAAG,gBAAuB,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,IAAA,oBAAa,EAAC,iBAAiB,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;QACvE,SAAiB,CAAC,KAAK,GAAG,CAAC,OAAe,EAAE,EAAE;YAC7C,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;YAEzB,OAAO,IAAA,oBAAa,EAClB,SAAS,EACT,MAAM,CAAC,OAAO;gBACZ,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;oBACrB,0GAA0G;oBAC1G,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;oBAEnE,IAAI,QAAQ,KAAK,UAAU,EAAE;wBAC3B,KAAK,CAAC,YAAY,CAAC,SAAS,CAC1B,cAAc,EACd,IAAA,gBAAS,EAAC,YAAY,EAAE;4BACtB,CAAC,QAAQ,CAAC,EAAE;gCACV,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO;6BAC9B;yBACF,CAAC,CACH,CAAC;qBACH;yBAAM;wBACL,KAAK,CAAC,UAAU,CAAC,SAAS,CACxB,cAAc,EACd,IAAA,gBAAS,EAAC,YAAY,EAAE;4BACtB,CAAC,QAAQ,CAAC,EAAE,OAAO;yBACpB,CAAC,CACH,CAAC;qBACH;gBACH,CAAC,CAAC,CACL,CAAC;QACJ,CAAC,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC,CAAQ,CAAC;AACZ,CAAC;AAzCD,oCAyCC"}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import { useDecorators } from "@tsed/core";
|
|
2
|
-
import {
|
|
1
|
+
import { deepMerge, useDecorators } from "@tsed/core";
|
|
2
|
+
import { JsonEntityFn } from "../decorators/common/jsonEntityFn.js";
|
|
3
3
|
export function withErrorMsg(errorKey, originalDecorator) {
|
|
4
4
|
const schema = {};
|
|
5
5
|
return ((...decoratorOptions) => {
|
|
6
6
|
const decorator = useDecorators(originalDecorator(...decoratorOptions));
|
|
7
7
|
decorator.Error = (message) => {
|
|
8
8
|
schema.message = message;
|
|
9
|
-
return useDecorators(decorator, schema.message &&
|
|
9
|
+
return useDecorators(decorator, schema.message &&
|
|
10
|
+
JsonEntityFn((store) => {
|
|
11
|
+
// since errorMessage is a custom key, it is prefixed with a # to avoid conflict with JSON Schema keywords
|
|
12
|
+
const errorMessage = store.parentSchema.get("#errorMessage") || {};
|
|
13
|
+
if (errorKey === "required") {
|
|
14
|
+
store.parentSchema.customKey("errorMessage", deepMerge(errorMessage, {
|
|
15
|
+
[errorKey]: {
|
|
16
|
+
[store.propertyName]: message
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
store.itemSchema.customKey("errorMessage", deepMerge(errorMessage, {
|
|
22
|
+
[errorKey]: message
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
10
26
|
};
|
|
11
27
|
return decorator;
|
|
12
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withErrorMsg.js","sourceRoot":"","sources":["../../../src/utils/withErrorMsg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,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AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/schema",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.70.1",
|
|
4
4
|
"description": "JsonSchema module for Ts.ED Framework",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"tsed"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tsed/openspec": "7.
|
|
36
|
+
"@tsed/openspec": "7.70.1",
|
|
37
37
|
"change-case": "^4.1.2",
|
|
38
38
|
"fs-extra": "^11.2.0",
|
|
39
39
|
"json-schema": "0.4.0",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@apidevtools/swagger-parser": "10.1.0",
|
|
46
|
-
"@tsed/core": "7.
|
|
47
|
-
"@tsed/openspec": "7.
|
|
48
|
-
"@tsed/typescript": "7.
|
|
46
|
+
"@tsed/core": "7.70.1",
|
|
47
|
+
"@tsed/openspec": "7.70.1",
|
|
48
|
+
"@tsed/typescript": "7.70.1",
|
|
49
49
|
"@types/fs-extra": "11.0.4",
|
|
50
50
|
"@types/json-schema": "7.0.15",
|
|
51
51
|
"@types/picomatch": "2.3.3",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"picomatch-browser": "^2.2.6"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@tsed/core": "7.
|
|
60
|
-
"@tsed/openspec": "7.
|
|
59
|
+
"@tsed/core": "7.70.1",
|
|
60
|
+
"@tsed/openspec": "7.70.1"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"@tsed/core": {
|