@tsed/schema 7.10.0 → 7.11.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/lib/browser/schema.umd.min.js +1 -1
- package/lib/browser/schema.umd.min.js.map +1 -1
- package/lib/cjs/decorators/collections/maxItems.js +4 -3
- package/lib/cjs/decorators/collections/maxItems.js.map +1 -1
- package/lib/cjs/decorators/collections/maxProperties.js +4 -3
- package/lib/cjs/decorators/collections/maxProperties.js.map +1 -1
- package/lib/cjs/decorators/collections/minItems.js +4 -3
- package/lib/cjs/decorators/collections/minItems.js.map +1 -1
- package/lib/cjs/decorators/collections/minProperties.js +4 -3
- package/lib/cjs/decorators/collections/minProperties.js.map +1 -1
- package/lib/cjs/decorators/collections/uniqueItems.js +4 -3
- package/lib/cjs/decorators/collections/uniqueItems.js.map +1 -1
- package/lib/cjs/decorators/common/defaultMsg.js +41 -0
- package/lib/cjs/decorators/common/defaultMsg.js.map +1 -0
- package/lib/cjs/decorators/common/enum.js +100 -2
- package/lib/cjs/decorators/common/enum.js.map +1 -1
- package/lib/cjs/decorators/common/errorMsg.js +20 -0
- package/lib/cjs/decorators/common/errorMsg.js.map +1 -0
- package/lib/cjs/decorators/common/exclusiveMaximum.js +4 -3
- package/lib/cjs/decorators/common/exclusiveMaximum.js.map +1 -1
- package/lib/cjs/decorators/common/exclusiveMinimum.js +4 -3
- package/lib/cjs/decorators/common/exclusiveMinimum.js.map +1 -1
- package/lib/cjs/decorators/common/format.js +28 -27
- package/lib/cjs/decorators/common/format.js.map +1 -1
- package/lib/cjs/decorators/common/maxLength.js +4 -3
- package/lib/cjs/decorators/common/maxLength.js.map +1 -1
- package/lib/cjs/decorators/common/maximum.js +5 -7
- package/lib/cjs/decorators/common/maximum.js.map +1 -1
- package/lib/cjs/decorators/common/minLength.js +4 -3
- package/lib/cjs/decorators/common/minLength.js.map +1 -1
- package/lib/cjs/decorators/common/minimum.js +5 -7
- package/lib/cjs/decorators/common/minimum.js.map +1 -1
- package/lib/cjs/decorators/common/multipleOf.js +4 -3
- package/lib/cjs/decorators/common/multipleOf.js.map +1 -1
- package/lib/cjs/decorators/common/pattern.js +4 -3
- package/lib/cjs/decorators/common/pattern.js.map +1 -1
- package/lib/cjs/decorators/common/required.js +3 -3
- package/lib/cjs/decorators/common/required.js.map +1 -1
- package/lib/cjs/decorators/common/typeError.js +18 -0
- package/lib/cjs/decorators/common/typeError.js.map +1 -0
- package/lib/cjs/domain/JsonSchema.js +3 -0
- package/lib/cjs/domain/JsonSchema.js.map +1 -1
- package/lib/cjs/index.js +4 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/withErrorMsg.js +18 -0
- package/lib/cjs/utils/withErrorMsg.js.map +1 -0
- package/lib/esm/decorators/collections/maxItems.js +4 -2
- package/lib/esm/decorators/collections/maxItems.js.map +1 -1
- package/lib/esm/decorators/collections/maxProperties.js +4 -2
- package/lib/esm/decorators/collections/maxProperties.js.map +1 -1
- package/lib/esm/decorators/collections/minItems.js +4 -2
- package/lib/esm/decorators/collections/minItems.js.map +1 -1
- package/lib/esm/decorators/collections/minProperties.js +4 -2
- package/lib/esm/decorators/collections/minProperties.js.map +1 -1
- package/lib/esm/decorators/collections/uniqueItems.js +4 -2
- package/lib/esm/decorators/collections/uniqueItems.js.map +1 -1
- package/lib/esm/decorators/common/defaultMsg.js +37 -0
- package/lib/esm/decorators/common/defaultMsg.js.map +1 -0
- package/lib/esm/decorators/common/enum.js +100 -1
- package/lib/esm/decorators/common/enum.js.map +1 -1
- package/lib/esm/decorators/common/errorMsg.js +16 -0
- package/lib/esm/decorators/common/errorMsg.js.map +1 -0
- package/lib/esm/decorators/common/exclusiveMaximum.js +4 -2
- package/lib/esm/decorators/common/exclusiveMaximum.js.map +1 -1
- package/lib/esm/decorators/common/exclusiveMinimum.js +4 -2
- package/lib/esm/decorators/common/exclusiveMinimum.js.map +1 -1
- package/lib/esm/decorators/common/format.js +22 -14
- package/lib/esm/decorators/common/format.js.map +1 -1
- package/lib/esm/decorators/common/maxLength.js +4 -2
- package/lib/esm/decorators/common/maxLength.js.map +1 -1
- package/lib/esm/decorators/common/maximum.js +5 -5
- package/lib/esm/decorators/common/maximum.js.map +1 -1
- package/lib/esm/decorators/common/minLength.js +4 -2
- package/lib/esm/decorators/common/minLength.js.map +1 -1
- package/lib/esm/decorators/common/minimum.js +5 -5
- package/lib/esm/decorators/common/minimum.js.map +1 -1
- package/lib/esm/decorators/common/multipleOf.js +4 -2
- package/lib/esm/decorators/common/multipleOf.js.map +1 -1
- package/lib/esm/decorators/common/pattern.js +4 -2
- package/lib/esm/decorators/common/pattern.js.map +1 -1
- package/lib/esm/decorators/common/required.js +3 -2
- package/lib/esm/decorators/common/required.js.map +1 -1
- package/lib/esm/decorators/common/typeError.js +14 -0
- package/lib/esm/decorators/common/typeError.js.map +1 -0
- package/lib/esm/domain/JsonSchema.js +3 -0
- package/lib/esm/domain/JsonSchema.js.map +1 -1
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils/withErrorMsg.js +14 -0
- package/lib/esm/utils/withErrorMsg.js.map +1 -0
- package/lib/types/decorators/collections/maxItems.d.ts +2 -1
- package/lib/types/decorators/collections/maxProperties.d.ts +2 -1
- package/lib/types/decorators/collections/minItems.d.ts +2 -1
- package/lib/types/decorators/collections/minProperties.d.ts +2 -1
- package/lib/types/decorators/collections/uniqueItems.d.ts +2 -1
- package/lib/types/decorators/common/defaultMsg.d.ts +32 -0
- package/lib/types/decorators/common/enum.d.ts +4 -1
- package/lib/types/decorators/common/errorMsg.d.ts +8 -0
- package/lib/types/decorators/common/exclusiveMaximum.d.ts +2 -1
- package/lib/types/decorators/common/exclusiveMinimum.d.ts +2 -1
- package/lib/types/decorators/common/format.d.ts +14 -7
- package/lib/types/decorators/common/maxLength.d.ts +2 -1
- package/lib/types/decorators/common/maximum.d.ts +3 -2
- package/lib/types/decorators/common/minLength.d.ts +2 -1
- package/lib/types/decorators/common/minimum.d.ts +3 -2
- package/lib/types/decorators/common/multipleOf.d.ts +2 -1
- package/lib/types/decorators/common/pattern.d.ts +2 -1
- package/lib/types/decorators/common/required.d.ts +1 -1
- package/lib/types/decorators/common/typeError.d.ts +8 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/utils/withErrorMsg.d.ts +6 -0
- package/package.json +6 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MaxItems = void 0;
|
|
4
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
4
5
|
const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
5
6
|
/**
|
|
6
7
|
* The value `maxItems` MUST be a non-negative integer.
|
|
@@ -47,14 +48,14 @@ const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
|
47
48
|
* @schema
|
|
48
49
|
* @input
|
|
49
50
|
* @collections
|
|
51
|
+
* @ajv-errors
|
|
50
52
|
*/
|
|
51
|
-
|
|
53
|
+
exports.MaxItems = (0, withErrorMsg_1.withErrorMsg)("maxItems", (maxItems) => {
|
|
52
54
|
if (maxItems < 0) {
|
|
53
55
|
throw new Error("The value of maxItems MUST be a non-negative integer.");
|
|
54
56
|
}
|
|
55
57
|
return (0, jsonEntityFn_1.JsonEntityFn)((storedJson) => {
|
|
56
58
|
storedJson.schema.maxItems(maxItems);
|
|
57
59
|
});
|
|
58
|
-
}
|
|
59
|
-
exports.MaxItems = MaxItems;
|
|
60
|
+
});
|
|
60
61
|
//# sourceMappingURL=maxItems.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maxItems.js","sourceRoot":"","sources":["../../../../src/decorators/collections/maxItems.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAEpD
|
|
1
|
+
{"version":3,"file":"maxItems.js","sourceRoot":"","sources":["../../../../src/decorators/collections/maxItems.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AACtD,yDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACU,QAAA,QAAQ,GAAG,IAAA,2BAAY,EAAC,UAAU,EAAE,CAAC,QAAgB,EAAE,EAAE;IACpE,IAAI,QAAQ,GAAG,CAAC,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KAC1E;IAED,OAAO,IAAA,2BAAY,EAAC,CAAC,UAAU,EAAE,EAAE;QACjC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\n\n/**\n * The value `maxItems` MUST be a non-negative integer.\n *\n * An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.\n *\n * :: warning\n * The value `maxItems` MUST be a non-negative integer.\n * :::\n *\n * :: warning\n * This decorator will be removed in v7.\n * For v6 user, use @@MaxItems@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n *\n * ```typescript\n * class Model {\n * @CollectionOf(String)\n * @MaxItems(10)\n * property: string[];\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"number\",\n * \"maxItems\": 10\n * }\n * }\n * }\n * ```\n *\n * @param {number} maxItems\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n * @ajv-errors\n */\nexport const MaxItems = withErrorMsg(\"maxItems\", (maxItems: number) => {\n if (maxItems < 0) {\n throw new Error(\"The value of maxItems MUST be a non-negative integer.\");\n }\n\n return JsonEntityFn((storedJson) => {\n storedJson.schema.maxItems(maxItems);\n });\n});\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MaxProperties = void 0;
|
|
4
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
4
5
|
const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
5
6
|
/**
|
|
6
7
|
* An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.
|
|
@@ -70,14 +71,14 @@ const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
|
70
71
|
* @schema
|
|
71
72
|
* @input
|
|
72
73
|
* @collections
|
|
74
|
+
* @ajv-errors
|
|
73
75
|
*/
|
|
74
|
-
|
|
76
|
+
exports.MaxProperties = (0, withErrorMsg_1.withErrorMsg)("maxProperties", (maxProperties) => {
|
|
75
77
|
if (maxProperties < 0) {
|
|
76
78
|
throw new Error("The value of maxProperties MUST be a non-negative integer.");
|
|
77
79
|
}
|
|
78
80
|
return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
|
|
79
81
|
store.isCollection ? store.schema.maxProperties(maxProperties) : store.itemSchema.maxProperties(maxProperties);
|
|
80
82
|
});
|
|
81
|
-
}
|
|
82
|
-
exports.MaxProperties = MaxProperties;
|
|
83
|
+
});
|
|
83
84
|
//# sourceMappingURL=maxProperties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maxProperties.js","sourceRoot":"","sources":["../../../../src/decorators/collections/maxProperties.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAEpD
|
|
1
|
+
{"version":3,"file":"maxProperties.js","sourceRoot":"","sources":["../../../../src/decorators/collections/maxProperties.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AACtD,yDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACU,QAAA,aAAa,GAAG,IAAA,2BAAY,EAAC,eAAe,EAAE,CAAC,aAAqB,EAAE,EAAE;IACnF,IAAI,aAAa,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;KAC/E;IAED,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACjH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\n\n/**\n * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n *\n * ::: warning\n * This decorator will be removed in v7.\n * For v6 user, use @@MaxProperties@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### On prop\n * ```typescript\n * class Model {\n * @MaxProperties(10)\n * property: any;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"any\",\n * \"maxProperties\": 10\n * }\n * }\n * }\n * ```\n *\n * ### On class\n *\n * ```typescript\n * @MaxProperties(10)\n * class Model {\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"maxProperties\": 10\n * }\n * ```\n *\n * ### On Parameter\n *\n * ```typescript\n *\n * class Model {\n * method(@Any() @MaxProperties(10) obj: any){}\n * }\n * ```\n *\n * @param {number} maxProperties The maximum properties allowed on the given object\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n * @ajv-errors\n */\nexport const MaxProperties = withErrorMsg(\"maxProperties\", (maxProperties: number) => {\n if (maxProperties < 0) {\n throw new Error(\"The value of maxProperties MUST be a non-negative integer.\");\n }\n\n return JsonEntityFn((store) => {\n store.isCollection ? store.schema.maxProperties(maxProperties) : store.itemSchema.maxProperties(maxProperties);\n });\n});\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MinItems = void 0;
|
|
4
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
4
5
|
const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
5
6
|
/**
|
|
6
7
|
* An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.
|
|
@@ -51,14 +52,14 @@ const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
|
51
52
|
* @schema
|
|
52
53
|
* @input
|
|
53
54
|
* @collections
|
|
55
|
+
* @ajv-errors
|
|
54
56
|
*/
|
|
55
|
-
|
|
57
|
+
exports.MinItems = (0, withErrorMsg_1.withErrorMsg)("minItems", (minItems) => {
|
|
56
58
|
if (minItems < 0) {
|
|
57
59
|
throw new Error("The value of minItems MUST be a non-negative integer.");
|
|
58
60
|
}
|
|
59
61
|
return (0, jsonEntityFn_1.JsonEntityFn)((storedJson) => {
|
|
60
62
|
storedJson.schema.minItems(minItems);
|
|
61
63
|
});
|
|
62
|
-
}
|
|
63
|
-
exports.MinItems = MinItems;
|
|
64
|
+
});
|
|
64
65
|
//# sourceMappingURL=minItems.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minItems.js","sourceRoot":"","sources":["../../../../src/decorators/collections/minItems.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAEpD
|
|
1
|
+
{"version":3,"file":"minItems.js","sourceRoot":"","sources":["../../../../src/decorators/collections/minItems.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AACtD,yDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACU,QAAA,QAAQ,GAAG,IAAA,2BAAY,EAAC,UAAU,EAAE,CAAC,QAAgB,EAAE,EAAE;IACpE,IAAI,QAAQ,GAAG,CAAC,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KAC1E;IAED,OAAO,IAAA,2BAAY,EAAC,CAAC,UAAU,EAAE,EAAE;QACjC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\n\n/**\n * An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value `minItems` MUST be a non-negative integer.\n * :::\n *\n * ::: tip\n * Omitting this keyword has the same behavior as a value of 0.\n * :::\n *\n * ::: warning\n * For v6 user, use @@MinItems@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n *\n * ```typescript\n * class Model {\n * @CollectionOf(String)\n * @MinItems(10)\n * property: string[];\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"array\",\n * \"minItems\": 10,\n * \"items\": {\n * \"type\": \"string\"\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} minItems\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n * @ajv-errors\n */\nexport const MinItems = withErrorMsg(\"minItems\", (minItems: number) => {\n if (minItems < 0) {\n throw new Error(\"The value of minItems MUST be a non-negative integer.\");\n }\n\n return JsonEntityFn((storedJson) => {\n storedJson.schema.minItems(minItems);\n });\n});\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MinProperties = void 0;
|
|
4
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
4
5
|
const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
5
6
|
/**
|
|
6
7
|
* An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.
|
|
@@ -69,14 +70,14 @@ const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
|
69
70
|
* @schema
|
|
70
71
|
* @input
|
|
71
72
|
* @collections
|
|
73
|
+
* @ajv-errors
|
|
72
74
|
*/
|
|
73
|
-
|
|
75
|
+
exports.MinProperties = (0, withErrorMsg_1.withErrorMsg)("minProperties", (minProperties) => {
|
|
74
76
|
if (minProperties < 0) {
|
|
75
77
|
throw new Error("The value of minProperties MUST be a non-negative integer.");
|
|
76
78
|
}
|
|
77
79
|
return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
|
|
78
80
|
store.isCollection ? store.schema.minProperties(minProperties) : store.itemSchema.minProperties(minProperties);
|
|
79
81
|
});
|
|
80
|
-
}
|
|
81
|
-
exports.MinProperties = MinProperties;
|
|
82
|
+
});
|
|
82
83
|
//# sourceMappingURL=minProperties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minProperties.js","sourceRoot":"","sources":["../../../../src/decorators/collections/minProperties.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAEpD
|
|
1
|
+
{"version":3,"file":"minProperties.js","sourceRoot":"","sources":["../../../../src/decorators/collections/minProperties.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AACtD,yDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACU,QAAA,aAAa,GAAG,IAAA,2BAAY,EAAC,eAAe,EAAE,CAAC,aAAqB,EAAE,EAAE;IACnF,IAAI,aAAa,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;KAC/E;IAED,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACjH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\n\n/**\n * An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n *\n * ::: warning\n * For v6 user, use @@MinProperties@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### On prop\n * ```typescript\n * class Model {\n * @MinProperties(10)\n * property: any;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"any\",\n * \"minProperties\": 10\n * }\n * }\n * }\n * ```\n *\n * ### On class\n *\n * ```typescript\n * @MinProperties(10)\n * class Model {\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"minProperties\": 10\n * }\n * ```\n *\n * ### On Parameter\n *\n * ```typescript\n *\n * class Model {\n * method(@Any() @MinProperties(10) obj: any){}\n * }\n * ```\n *\n * @param {number} minProperties The minimum properties allowed on the object.\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n * @ajv-errors\n */\nexport const MinProperties = withErrorMsg(\"minProperties\", (minProperties: number) => {\n if (minProperties < 0) {\n throw new Error(\"The value of minProperties MUST be a non-negative integer.\");\n }\n\n return JsonEntityFn((store) => {\n store.isCollection ? store.schema.minProperties(minProperties) : store.itemSchema.minProperties(minProperties);\n });\n});\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UniqueItems = void 0;
|
|
4
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
4
5
|
const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
5
6
|
/**
|
|
6
7
|
* If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.
|
|
@@ -50,11 +51,11 @@ const jsonEntityFn_1 = require("../common/jsonEntityFn");
|
|
|
50
51
|
* @schema
|
|
51
52
|
* @input
|
|
52
53
|
* @collections
|
|
54
|
+
* @ajv-errors
|
|
53
55
|
*/
|
|
54
|
-
|
|
56
|
+
exports.UniqueItems = (0, withErrorMsg_1.withErrorMsg)("uniqueItems", (uniqueItems = true) => {
|
|
55
57
|
return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
|
|
56
58
|
store.schema.uniqueItems(uniqueItems);
|
|
57
59
|
});
|
|
58
|
-
}
|
|
59
|
-
exports.UniqueItems = UniqueItems;
|
|
60
|
+
});
|
|
60
61
|
//# sourceMappingURL=uniqueItems.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniqueItems.js","sourceRoot":"","sources":["../../../../src/decorators/collections/uniqueItems.ts"],"names":[],"mappings":";;;AACA,yDAAoD;AAEpD
|
|
1
|
+
{"version":3,"file":"uniqueItems.js","sourceRoot":"","sources":["../../../../src/decorators/collections/uniqueItems.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AACtD,yDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACU,QAAA,WAAW,GAAG,IAAA,2BAAY,EAAC,aAAa,EAAE,CAAC,cAAuB,IAAI,EAAE,EAAE;IACrF,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAsB,EAAE,EAAE;QAC7C,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\n\n/**\n * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.\n *\n * ::: warning\n * For v6 user, use @@UniqueItems@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n *\n * ```typescript\n * class Model {\n * @UniqueItems() // default true\n * property: number[];\n * }\n * ```\n *\n * * ```typescript\n * class Model {\n * @CollectionOf(String)\n * @UniqueItems()\n * property: string[];\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"array\",\n * \"uniqueItems\": true,\n * \"items\": {\n * \"type\": \"string\"\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {boolean} uniqueItems\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n * @ajv-errors\n */\nexport const UniqueItems = withErrorMsg(\"uniqueItems\", (uniqueItems: boolean = true) => {\n return JsonEntityFn((store: JsonEntityStore) => {\n store.schema.uniqueItems(uniqueItems);\n });\n});\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultMsg = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const errorMsg_1 = require("./errorMsg");
|
|
6
|
+
/**
|
|
7
|
+
* Set default error message.
|
|
8
|
+
*
|
|
9
|
+
* ## Example
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @DefaultMessage("foo should be a string")
|
|
13
|
+
* class Model {
|
|
14
|
+
* property: number;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Will produce:
|
|
19
|
+
*
|
|
20
|
+
* ```json
|
|
21
|
+
* {
|
|
22
|
+
* "type": "object",
|
|
23
|
+
* "properties": {
|
|
24
|
+
* "property": "number"
|
|
25
|
+
* }
|
|
26
|
+
* "errorMessage": {
|
|
27
|
+
* "_": "foo should be a string"
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @decorator
|
|
33
|
+
* @validation
|
|
34
|
+
* @swagger
|
|
35
|
+
* @schema
|
|
36
|
+
*/
|
|
37
|
+
function DefaultMsg(message) {
|
|
38
|
+
return (0, core_1.useDecorators)((0, errorMsg_1.ErrorMsg)({ _: message }));
|
|
39
|
+
}
|
|
40
|
+
exports.DefaultMsg = DefaultMsg;
|
|
41
|
+
//# sourceMappingURL=defaultMsg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultMsg.js","sourceRoot":"","sources":["../../../../src/decorators/common/defaultMsg.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,yCAAoC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,SAAgB,UAAU,CAAC,OAAe;IACxC,OAAO,IAAA,oBAAa,EAAC,IAAA,mBAAQ,EAAC,EAAC,CAAC,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAFD,gCAEC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {ErrorMsg} from \"./errorMsg\";\n\n/**\n * Set default error message.\n *\n * ## Example\n *\n * ```typescript\n * @DefaultMessage(\"foo should be a string\")\n * class Model {\n * property: number;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": \"number\"\n * }\n * \"errorMessage\": {\n * \"_\": \"foo should be a string\"\n * }\n * }\n * ```\n *\n * @decorator\n * @validation\n * @swagger\n * @schema\n */\nexport function DefaultMsg(message: string): ClassDecorator {\n return useDecorators(ErrorMsg({_: message}));\n}\n"]}
|
|
@@ -1,11 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Enum = void 0;
|
|
4
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
4
5
|
const jsonEntityFn_1 = require("./jsonEntityFn");
|
|
5
|
-
function
|
|
6
|
+
function EnumFn(enumValue, ...enumValues) {
|
|
6
7
|
return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
|
|
7
8
|
store.itemSchema.enum(enumValue, ...enumValues);
|
|
8
9
|
});
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The enum keyword is used to restrict a value to a fixed set of values.
|
|
13
|
+
* It must be an array with at least one element, where each element is unique.
|
|
14
|
+
*
|
|
15
|
+
* Elements in the array might be of any value, including null.
|
|
16
|
+
*
|
|
17
|
+
* ::: warning
|
|
18
|
+
* For v6 user, use @@Enum@@ from @tsed/schema instead of @tsed/common.
|
|
19
|
+
* :::
|
|
20
|
+
*
|
|
21
|
+
* ## Example
|
|
22
|
+
* ### With primitive type
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* class Model {
|
|
26
|
+
* @Enum("value1", "value2")
|
|
27
|
+
* property: "value1" | "value2";
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Will produce:
|
|
32
|
+
*
|
|
33
|
+
* ```json
|
|
34
|
+
* {
|
|
35
|
+
* "type": "object",
|
|
36
|
+
* "properties": {
|
|
37
|
+
* "property": {
|
|
38
|
+
* "type": "string",
|
|
39
|
+
* "enum": ["value1", "value2"]
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* ### With array type
|
|
46
|
+
*
|
|
47
|
+
* ```typescript
|
|
48
|
+
* class Model {
|
|
49
|
+
* @Enum("value1", "value2")
|
|
50
|
+
* property: ("value1" | "value2")[];
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Will produce:
|
|
55
|
+
*
|
|
56
|
+
* ```json
|
|
57
|
+
* {
|
|
58
|
+
* "type": "object",
|
|
59
|
+
* "properties": {
|
|
60
|
+
* "property": {
|
|
61
|
+
* "type": "array",
|
|
62
|
+
* "items": {
|
|
63
|
+
* "type": "string",
|
|
64
|
+
* "enum": ["value1", "value2"]
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* ### With Typescript Enum
|
|
72
|
+
*
|
|
73
|
+
* ```typescript
|
|
74
|
+
* enum SomeEnum {
|
|
75
|
+
* ENUM_1 = "enum1",
|
|
76
|
+
* ENUM_2 = "enum2"
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* class Model {
|
|
80
|
+
* @Enum(SomeEnum)
|
|
81
|
+
* property: SomeEnum;
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* Will produce:
|
|
86
|
+
*
|
|
87
|
+
* ```json
|
|
88
|
+
* {
|
|
89
|
+
* "type": "object",
|
|
90
|
+
* "properties": {
|
|
91
|
+
* "property": {
|
|
92
|
+
* "type": "string",
|
|
93
|
+
* "enum": ["enum1", "enum2"]
|
|
94
|
+
* }
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param {string | number | boolean | {}} enumValue
|
|
100
|
+
* @param enumValues
|
|
101
|
+
* @decorator
|
|
102
|
+
* @validation
|
|
103
|
+
* @swagger
|
|
104
|
+
* @schema
|
|
105
|
+
* @input
|
|
106
|
+
* @ajv-errors
|
|
107
|
+
*/
|
|
108
|
+
exports.Enum = (0, withErrorMsg_1.withErrorMsg)("enum", EnumFn);
|
|
11
109
|
//# sourceMappingURL=enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/decorators/common/enum.ts"],"names":[],"mappings":";;;AACA,iDAA4C;
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/decorators/common/enum.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AACtD,iDAA4C;AAG5C,SAAS,MAAM,CAAC,SAAgC,EAAE,GAAG,UAA6B;IAChF,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,UAAU,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AAEU,QAAA,IAAI,GAAG,IAAA,2BAAY,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC","sourcesContent":["import type {JSONSchema6Type} from \"json-schema\";\nimport {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\nfunction EnumFn(...enumValues: (JSONSchema6Type | any)[]): Function;\nfunction EnumFn(enumValue: JSONSchema6Type | any, ...enumValues: JSONSchema6Type[]) {\n return JsonEntityFn((store) => {\n store.itemSchema.enum(enumValue, ...enumValues);\n });\n}\n\n/**\n * The enum keyword is used to restrict a value to a fixed set of values.\n * It must be an array with at least one element, where each element is unique.\n *\n * Elements in the array might be of any value, including null.\n *\n * ::: warning\n * For v6 user, use @@Enum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Enum(\"value1\", \"value2\")\n * property: \"value1\" | \"value2\";\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"enum\": [\"value1\", \"value2\"]\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Enum(\"value1\", \"value2\")\n * property: (\"value1\" | \"value2\")[];\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"array\",\n * \"items\": {\n * \"type\": \"string\",\n * \"enum\": [\"value1\", \"value2\"]\n * }\n * }\n * }\n * }\n * ```\n *\n * ### With Typescript Enum\n *\n * ```typescript\n * enum SomeEnum {\n * ENUM_1 = \"enum1\",\n * ENUM_2 = \"enum2\"\n * }\n *\n * class Model {\n * @Enum(SomeEnum)\n * property: SomeEnum;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"enum\": [\"enum1\", \"enum2\"]\n * }\n * }\n * }\n * ```\n *\n * @param {string | number | boolean | {}} enumValue\n * @param enumValues\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\n\nexport const Enum = withErrorMsg(\"enum\", EnumFn);\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorMsg = void 0;
|
|
4
|
+
const jsonEntityFn_1 = require("./jsonEntityFn");
|
|
5
|
+
/**
|
|
6
|
+
* Create a new custom formats validator
|
|
7
|
+
* @param name
|
|
8
|
+
* @param options
|
|
9
|
+
* @decorator
|
|
10
|
+
* @ajv
|
|
11
|
+
*/
|
|
12
|
+
function ErrorMsg(obj) {
|
|
13
|
+
return (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
|
+
store.parentSchema.customKey("errorMessage", { ...errorMessage, ...obj });
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.ErrorMsg = ErrorMsg;
|
|
20
|
+
//# sourceMappingURL=errorMsg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorMsg.js","sourceRoot":"","sources":["../../../../src/decorators/common/errorMsg.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,GAA2B;IAClD,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,0GAA0G;QAC1G,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;QACnE,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,cAAc,EAAE,EAAC,GAAG,YAAY,EAAE,GAAG,GAAG,EAAC,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC;AAND,4BAMC","sourcesContent":["import {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * Create a new custom formats validator\n * @param name\n * @param options\n * @decorator\n * @ajv\n */\nexport function ErrorMsg(obj: Record<string, string>) {\n return JsonEntityFn((store) => {\n // since errorMessage is a custom key, it is prefixed with a # to avoid conflict with JSON Schema keywords\n const errorMessage = store.parentSchema.get(\"#errorMessage\") || {};\n store.parentSchema.customKey(\"errorMessage\", {...errorMessage, ...obj});\n });\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExclusiveMaximum = void 0;
|
|
4
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
4
5
|
const maximum_1 = require("./maximum");
|
|
5
6
|
/**
|
|
6
7
|
* The value of `exclusiveMaximum` MUST be number, representing an exclusive upper limit for a numeric instance.
|
|
@@ -69,9 +70,9 @@ const maximum_1 = require("./maximum");
|
|
|
69
70
|
* @swagger
|
|
70
71
|
* @schema
|
|
71
72
|
* @input
|
|
73
|
+
* @ajv-errors
|
|
72
74
|
*/
|
|
73
|
-
|
|
75
|
+
exports.ExclusiveMaximum = (0, withErrorMsg_1.withErrorMsg)("exclusiveMaximum", (maximum, exclusiveMaximum = true) => {
|
|
74
76
|
return (0, maximum_1.Maximum)(maximum, exclusiveMaximum);
|
|
75
|
-
}
|
|
76
|
-
exports.ExclusiveMaximum = ExclusiveMaximum;
|
|
77
|
+
});
|
|
77
78
|
//# sourceMappingURL=exclusiveMaximum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exclusiveMaximum.js","sourceRoot":"","sources":["../../../../src/decorators/common/exclusiveMaximum.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAElC
|
|
1
|
+
{"version":3,"file":"exclusiveMaximum.js","sourceRoot":"","sources":["../../../../src/decorators/common/exclusiveMaximum.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AACtD,uCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACU,QAAA,gBAAgB,GAAG,IAAA,2BAAY,EAAC,kBAAkB,EAAE,CAAC,OAAe,EAAE,mBAA4B,IAAI,EAAE,EAAE;IACrH,OAAO,IAAA,iBAAO,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {Maximum} from \"./maximum\";\n\n/**\n * The value of `exclusiveMaximum` MUST be number, representing an exclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then the instance is valid only if it has a value strictly less than (not equal to) `exclusiveMaximum`.\n *\n * ::: warning\n * For v6 user, use @@ExclusiveMaximum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @ExclusiveMaximum(10)\n * property: number;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"number\",\n * \"exclusiveMaximum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @ExclusiveMaximum(10)\n * @CollectionOf(Number)\n * property: number[];\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"array\",\n * \"items\": {\n * \"type\": \"number\",\n * \"exclusiveMaximum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param maximum\n * @param {boolean} exclusiveMaximum\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const ExclusiveMaximum = withErrorMsg(\"exclusiveMaximum\", (maximum: number, exclusiveMaximum: boolean = true) => {\n return Maximum(maximum, exclusiveMaximum);\n});\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExclusiveMinimum = void 0;
|
|
4
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
4
5
|
const minimum_1 = require("./minimum");
|
|
5
6
|
/**
|
|
6
7
|
* The value of `exclusiveMinimum` MUST be number, representing an exclusive upper limit for a numeric instance.
|
|
@@ -69,9 +70,9 @@ const minimum_1 = require("./minimum");
|
|
|
69
70
|
* @swagger
|
|
70
71
|
* @schema
|
|
71
72
|
* @input
|
|
73
|
+
* @ajv-errors
|
|
72
74
|
*/
|
|
73
|
-
|
|
75
|
+
exports.ExclusiveMinimum = (0, withErrorMsg_1.withErrorMsg)("exclusiveMinimum", (minimum, exclusiveMinimum = true) => {
|
|
74
76
|
return (0, minimum_1.Minimum)(minimum, exclusiveMinimum);
|
|
75
|
-
}
|
|
76
|
-
exports.ExclusiveMinimum = ExclusiveMinimum;
|
|
77
|
+
});
|
|
77
78
|
//# sourceMappingURL=exclusiveMinimum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exclusiveMinimum.js","sourceRoot":"","sources":["../../../../src/decorators/common/exclusiveMinimum.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAElC
|
|
1
|
+
{"version":3,"file":"exclusiveMinimum.js","sourceRoot":"","sources":["../../../../src/decorators/common/exclusiveMinimum.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AACtD,uCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACU,QAAA,gBAAgB,GAAG,IAAA,2BAAY,EAAC,kBAAkB,EAAE,CAAC,OAAe,EAAE,mBAA4B,IAAI,EAAE,EAAE;IACrH,OAAO,IAAA,iBAAO,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {Minimum} from \"./minimum\";\n\n/**\n * The value of `exclusiveMinimum` MUST be number, representing an exclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then the instance is valid only if it has a value strictly greater than (not equal to) `exclusiveMinimum`.\n *\n * ::: warning\n * For v6 user, use @@ExclusiveMinimum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @ExclusiveMinimum(10)\n * property: number;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"number\",\n * \"exclusiveMinimum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @ExclusiveMinimum(10)\n * @CollectionOf(Number)\n * property: number[];\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"array\",\n * \"items\": {\n * \"type\": \"number\",\n * \"exclusiveMinimum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param minimum\n * @param {boolean} exclusiveMinimum\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const ExclusiveMinimum = withErrorMsg(\"exclusiveMinimum\", (minimum: number, exclusiveMinimum: boolean = true) => {\n return Minimum(minimum, exclusiveMinimum);\n});\n"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Url = exports.Uri = exports.TimeFormat = exports.DateFormat = exports.DateTime = exports.Email = exports.Format = void 0;
|
|
4
4
|
const JsonFormatTypes_1 = require("../../domain/JsonFormatTypes");
|
|
5
|
+
const withErrorMsg_1 = require("../../utils/withErrorMsg");
|
|
5
6
|
const jsonEntityFn_1 = require("./jsonEntityFn");
|
|
6
7
|
/**
|
|
7
8
|
* The following formats are supported for string validation with `format` keyword:
|
|
@@ -75,13 +76,13 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
|
|
|
75
76
|
* @swagger
|
|
76
77
|
* @schema
|
|
77
78
|
* @input
|
|
79
|
+
* @ajv-errors
|
|
78
80
|
*/
|
|
79
|
-
|
|
81
|
+
exports.Format = (0, withErrorMsg_1.withErrorMsg)("format", (format) => {
|
|
80
82
|
return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
|
|
81
83
|
store.itemSchema.format(format);
|
|
82
84
|
});
|
|
83
|
-
}
|
|
84
|
-
exports.Format = Format;
|
|
85
|
+
});
|
|
85
86
|
/**
|
|
86
87
|
* Apply an email validation on property.
|
|
87
88
|
*
|
|
@@ -147,11 +148,11 @@ exports.Format = Format;
|
|
|
147
148
|
* @schema
|
|
148
149
|
* @swagger
|
|
149
150
|
* @input
|
|
151
|
+
* @ajv-errors
|
|
150
152
|
*/
|
|
151
|
-
|
|
152
|
-
return Format(JsonFormatTypes_1.JsonFormatTypes.EMAIL);
|
|
153
|
-
}
|
|
154
|
-
exports.Email = Email;
|
|
153
|
+
exports.Email = (0, withErrorMsg_1.withErrorMsg)("format", () => {
|
|
154
|
+
return (0, exports.Format)(JsonFormatTypes_1.JsonFormatTypes.EMAIL);
|
|
155
|
+
});
|
|
155
156
|
/**
|
|
156
157
|
* Apply a date-time validation on property.
|
|
157
158
|
*
|
|
@@ -214,11 +215,11 @@ exports.Email = Email;
|
|
|
214
215
|
* @parameter
|
|
215
216
|
* @schema
|
|
216
217
|
* @auto-map The data will be stored on the right place according to the type and collectionType (primitive or collection).
|
|
218
|
+
* @ajv-errors
|
|
217
219
|
*/
|
|
218
|
-
|
|
219
|
-
return Format(JsonFormatTypes_1.JsonFormatTypes.DATE_TIME);
|
|
220
|
-
}
|
|
221
|
-
exports.DateTime = DateTime;
|
|
220
|
+
exports.DateTime = (0, withErrorMsg_1.withErrorMsg)("format", () => {
|
|
221
|
+
return (0, exports.Format)(JsonFormatTypes_1.JsonFormatTypes.DATE_TIME);
|
|
222
|
+
});
|
|
222
223
|
/**
|
|
223
224
|
* Apply a time validation on property.
|
|
224
225
|
*
|
|
@@ -280,11 +281,11 @@ exports.DateTime = DateTime;
|
|
|
280
281
|
* @property
|
|
281
282
|
* @parameter
|
|
282
283
|
* @schema
|
|
284
|
+
* @ajv-errors
|
|
283
285
|
*/
|
|
284
|
-
|
|
285
|
-
return Format(JsonFormatTypes_1.JsonFormatTypes.DATE);
|
|
286
|
-
}
|
|
287
|
-
exports.DateFormat = DateFormat;
|
|
286
|
+
exports.DateFormat = (0, withErrorMsg_1.withErrorMsg)("format", () => {
|
|
287
|
+
return (0, exports.Format)(JsonFormatTypes_1.JsonFormatTypes.DATE);
|
|
288
|
+
});
|
|
288
289
|
/**
|
|
289
290
|
* Apply a time validation on property.
|
|
290
291
|
*
|
|
@@ -346,11 +347,11 @@ exports.DateFormat = DateFormat;
|
|
|
346
347
|
* @property
|
|
347
348
|
* @parameter
|
|
348
349
|
* @schema
|
|
350
|
+
* @ajv-errors
|
|
349
351
|
*/
|
|
350
|
-
|
|
351
|
-
return Format(JsonFormatTypes_1.JsonFormatTypes.TIME);
|
|
352
|
-
}
|
|
353
|
-
exports.TimeFormat = TimeFormat;
|
|
352
|
+
exports.TimeFormat = (0, withErrorMsg_1.withErrorMsg)("format", () => {
|
|
353
|
+
return (0, exports.Format)(JsonFormatTypes_1.JsonFormatTypes.TIME);
|
|
354
|
+
});
|
|
354
355
|
/**
|
|
355
356
|
* Apply a uri validation on property.
|
|
356
357
|
*
|
|
@@ -412,11 +413,11 @@ exports.TimeFormat = TimeFormat;
|
|
|
412
413
|
* @property
|
|
413
414
|
* @parameter
|
|
414
415
|
* @schema
|
|
416
|
+
* @ajv-errors
|
|
415
417
|
*/
|
|
416
|
-
|
|
417
|
-
return Format(JsonFormatTypes_1.JsonFormatTypes.URI);
|
|
418
|
-
}
|
|
419
|
-
exports.Uri = Uri;
|
|
418
|
+
exports.Uri = (0, withErrorMsg_1.withErrorMsg)("format", () => {
|
|
419
|
+
return (0, exports.Format)(JsonFormatTypes_1.JsonFormatTypes.URI);
|
|
420
|
+
});
|
|
420
421
|
/**
|
|
421
422
|
* Apply a url validation on property.
|
|
422
423
|
*
|
|
@@ -478,9 +479,9 @@ exports.Uri = Uri;
|
|
|
478
479
|
* @property
|
|
479
480
|
* @parameter
|
|
480
481
|
* @schema
|
|
482
|
+
* @ajv-errors
|
|
481
483
|
*/
|
|
482
|
-
|
|
483
|
-
return Format(JsonFormatTypes_1.JsonFormatTypes.URL);
|
|
484
|
-
}
|
|
485
|
-
exports.Url = Url;
|
|
484
|
+
exports.Url = (0, withErrorMsg_1.withErrorMsg)("format", () => {
|
|
485
|
+
return (0, exports.Format)(JsonFormatTypes_1.JsonFormatTypes.URL);
|
|
486
|
+
});
|
|
486
487
|
//# sourceMappingURL=format.js.map
|