@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.
Files changed (112) hide show
  1. package/lib/browser/schema.umd.min.js +1 -1
  2. package/lib/browser/schema.umd.min.js.map +1 -1
  3. package/lib/cjs/decorators/collections/maxItems.js +4 -3
  4. package/lib/cjs/decorators/collections/maxItems.js.map +1 -1
  5. package/lib/cjs/decorators/collections/maxProperties.js +4 -3
  6. package/lib/cjs/decorators/collections/maxProperties.js.map +1 -1
  7. package/lib/cjs/decorators/collections/minItems.js +4 -3
  8. package/lib/cjs/decorators/collections/minItems.js.map +1 -1
  9. package/lib/cjs/decorators/collections/minProperties.js +4 -3
  10. package/lib/cjs/decorators/collections/minProperties.js.map +1 -1
  11. package/lib/cjs/decorators/collections/uniqueItems.js +4 -3
  12. package/lib/cjs/decorators/collections/uniqueItems.js.map +1 -1
  13. package/lib/cjs/decorators/common/defaultMsg.js +41 -0
  14. package/lib/cjs/decorators/common/defaultMsg.js.map +1 -0
  15. package/lib/cjs/decorators/common/enum.js +100 -2
  16. package/lib/cjs/decorators/common/enum.js.map +1 -1
  17. package/lib/cjs/decorators/common/errorMsg.js +20 -0
  18. package/lib/cjs/decorators/common/errorMsg.js.map +1 -0
  19. package/lib/cjs/decorators/common/exclusiveMaximum.js +4 -3
  20. package/lib/cjs/decorators/common/exclusiveMaximum.js.map +1 -1
  21. package/lib/cjs/decorators/common/exclusiveMinimum.js +4 -3
  22. package/lib/cjs/decorators/common/exclusiveMinimum.js.map +1 -1
  23. package/lib/cjs/decorators/common/format.js +28 -27
  24. package/lib/cjs/decorators/common/format.js.map +1 -1
  25. package/lib/cjs/decorators/common/maxLength.js +4 -3
  26. package/lib/cjs/decorators/common/maxLength.js.map +1 -1
  27. package/lib/cjs/decorators/common/maximum.js +5 -7
  28. package/lib/cjs/decorators/common/maximum.js.map +1 -1
  29. package/lib/cjs/decorators/common/minLength.js +4 -3
  30. package/lib/cjs/decorators/common/minLength.js.map +1 -1
  31. package/lib/cjs/decorators/common/minimum.js +5 -7
  32. package/lib/cjs/decorators/common/minimum.js.map +1 -1
  33. package/lib/cjs/decorators/common/multipleOf.js +4 -3
  34. package/lib/cjs/decorators/common/multipleOf.js.map +1 -1
  35. package/lib/cjs/decorators/common/pattern.js +4 -3
  36. package/lib/cjs/decorators/common/pattern.js.map +1 -1
  37. package/lib/cjs/decorators/common/required.js +3 -3
  38. package/lib/cjs/decorators/common/required.js.map +1 -1
  39. package/lib/cjs/decorators/common/typeError.js +18 -0
  40. package/lib/cjs/decorators/common/typeError.js.map +1 -0
  41. package/lib/cjs/domain/JsonSchema.js +3 -0
  42. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  43. package/lib/cjs/index.js +4 -0
  44. package/lib/cjs/index.js.map +1 -1
  45. package/lib/cjs/utils/withErrorMsg.js +18 -0
  46. package/lib/cjs/utils/withErrorMsg.js.map +1 -0
  47. package/lib/esm/decorators/collections/maxItems.js +4 -2
  48. package/lib/esm/decorators/collections/maxItems.js.map +1 -1
  49. package/lib/esm/decorators/collections/maxProperties.js +4 -2
  50. package/lib/esm/decorators/collections/maxProperties.js.map +1 -1
  51. package/lib/esm/decorators/collections/minItems.js +4 -2
  52. package/lib/esm/decorators/collections/minItems.js.map +1 -1
  53. package/lib/esm/decorators/collections/minProperties.js +4 -2
  54. package/lib/esm/decorators/collections/minProperties.js.map +1 -1
  55. package/lib/esm/decorators/collections/uniqueItems.js +4 -2
  56. package/lib/esm/decorators/collections/uniqueItems.js.map +1 -1
  57. package/lib/esm/decorators/common/defaultMsg.js +37 -0
  58. package/lib/esm/decorators/common/defaultMsg.js.map +1 -0
  59. package/lib/esm/decorators/common/enum.js +100 -1
  60. package/lib/esm/decorators/common/enum.js.map +1 -1
  61. package/lib/esm/decorators/common/errorMsg.js +16 -0
  62. package/lib/esm/decorators/common/errorMsg.js.map +1 -0
  63. package/lib/esm/decorators/common/exclusiveMaximum.js +4 -2
  64. package/lib/esm/decorators/common/exclusiveMaximum.js.map +1 -1
  65. package/lib/esm/decorators/common/exclusiveMinimum.js +4 -2
  66. package/lib/esm/decorators/common/exclusiveMinimum.js.map +1 -1
  67. package/lib/esm/decorators/common/format.js +22 -14
  68. package/lib/esm/decorators/common/format.js.map +1 -1
  69. package/lib/esm/decorators/common/maxLength.js +4 -2
  70. package/lib/esm/decorators/common/maxLength.js.map +1 -1
  71. package/lib/esm/decorators/common/maximum.js +5 -5
  72. package/lib/esm/decorators/common/maximum.js.map +1 -1
  73. package/lib/esm/decorators/common/minLength.js +4 -2
  74. package/lib/esm/decorators/common/minLength.js.map +1 -1
  75. package/lib/esm/decorators/common/minimum.js +5 -5
  76. package/lib/esm/decorators/common/minimum.js.map +1 -1
  77. package/lib/esm/decorators/common/multipleOf.js +4 -2
  78. package/lib/esm/decorators/common/multipleOf.js.map +1 -1
  79. package/lib/esm/decorators/common/pattern.js +4 -2
  80. package/lib/esm/decorators/common/pattern.js.map +1 -1
  81. package/lib/esm/decorators/common/required.js +3 -2
  82. package/lib/esm/decorators/common/required.js.map +1 -1
  83. package/lib/esm/decorators/common/typeError.js +14 -0
  84. package/lib/esm/decorators/common/typeError.js.map +1 -0
  85. package/lib/esm/domain/JsonSchema.js +3 -0
  86. package/lib/esm/domain/JsonSchema.js.map +1 -1
  87. package/lib/esm/index.js +4 -0
  88. package/lib/esm/index.js.map +1 -1
  89. package/lib/esm/utils/withErrorMsg.js +14 -0
  90. package/lib/esm/utils/withErrorMsg.js.map +1 -0
  91. package/lib/types/decorators/collections/maxItems.d.ts +2 -1
  92. package/lib/types/decorators/collections/maxProperties.d.ts +2 -1
  93. package/lib/types/decorators/collections/minItems.d.ts +2 -1
  94. package/lib/types/decorators/collections/minProperties.d.ts +2 -1
  95. package/lib/types/decorators/collections/uniqueItems.d.ts +2 -1
  96. package/lib/types/decorators/common/defaultMsg.d.ts +32 -0
  97. package/lib/types/decorators/common/enum.d.ts +4 -1
  98. package/lib/types/decorators/common/errorMsg.d.ts +8 -0
  99. package/lib/types/decorators/common/exclusiveMaximum.d.ts +2 -1
  100. package/lib/types/decorators/common/exclusiveMinimum.d.ts +2 -1
  101. package/lib/types/decorators/common/format.d.ts +14 -7
  102. package/lib/types/decorators/common/maxLength.d.ts +2 -1
  103. package/lib/types/decorators/common/maximum.d.ts +3 -2
  104. package/lib/types/decorators/common/minLength.d.ts +2 -1
  105. package/lib/types/decorators/common/minimum.d.ts +3 -2
  106. package/lib/types/decorators/common/multipleOf.d.ts +2 -1
  107. package/lib/types/decorators/common/pattern.d.ts +2 -1
  108. package/lib/types/decorators/common/required.d.ts +1 -1
  109. package/lib/types/decorators/common/typeError.d.ts +8 -0
  110. package/lib/types/index.d.ts +4 -0
  111. package/lib/types/utils/withErrorMsg.d.ts +6 -0
  112. package/package.json +6 -6
@@ -1,7 +1,106 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "./jsonEntityFn.js";
2
- export function Enum(enumValue, ...enumValues) {
3
+ function EnumFn(enumValue, ...enumValues) {
3
4
  return JsonEntityFn((store) => {
4
5
  store.itemSchema.enum(enumValue, ...enumValues);
5
6
  });
6
7
  }
8
+ /**
9
+ * The enum keyword is used to restrict a value to a fixed set of values.
10
+ * It must be an array with at least one element, where each element is unique.
11
+ *
12
+ * Elements in the array might be of any value, including null.
13
+ *
14
+ * ::: warning
15
+ * For v6 user, use @@Enum@@ from @tsed/schema instead of @tsed/common.
16
+ * :::
17
+ *
18
+ * ## Example
19
+ * ### With primitive type
20
+ *
21
+ * ```typescript
22
+ * class Model {
23
+ * @Enum("value1", "value2")
24
+ * property: "value1" | "value2";
25
+ * }
26
+ * ```
27
+ *
28
+ * Will produce:
29
+ *
30
+ * ```json
31
+ * {
32
+ * "type": "object",
33
+ * "properties": {
34
+ * "property": {
35
+ * "type": "string",
36
+ * "enum": ["value1", "value2"]
37
+ * }
38
+ * }
39
+ * }
40
+ * ```
41
+ *
42
+ * ### With array type
43
+ *
44
+ * ```typescript
45
+ * class Model {
46
+ * @Enum("value1", "value2")
47
+ * property: ("value1" | "value2")[];
48
+ * }
49
+ * ```
50
+ *
51
+ * Will produce:
52
+ *
53
+ * ```json
54
+ * {
55
+ * "type": "object",
56
+ * "properties": {
57
+ * "property": {
58
+ * "type": "array",
59
+ * "items": {
60
+ * "type": "string",
61
+ * "enum": ["value1", "value2"]
62
+ * }
63
+ * }
64
+ * }
65
+ * }
66
+ * ```
67
+ *
68
+ * ### With Typescript Enum
69
+ *
70
+ * ```typescript
71
+ * enum SomeEnum {
72
+ * ENUM_1 = "enum1",
73
+ * ENUM_2 = "enum2"
74
+ * }
75
+ *
76
+ * class Model {
77
+ * @Enum(SomeEnum)
78
+ * property: SomeEnum;
79
+ * }
80
+ * ```
81
+ *
82
+ * Will produce:
83
+ *
84
+ * ```json
85
+ * {
86
+ * "type": "object",
87
+ * "properties": {
88
+ * "property": {
89
+ * "type": "string",
90
+ * "enum": ["enum1", "enum2"]
91
+ * }
92
+ * }
93
+ * }
94
+ * ```
95
+ *
96
+ * @param {string | number | boolean | {}} enumValue
97
+ * @param enumValues
98
+ * @decorator
99
+ * @validation
100
+ * @swagger
101
+ * @schema
102
+ * @input
103
+ * @ajv-errors
104
+ */
105
+ export const Enum = withErrorMsg("enum", EnumFn);
7
106
  //# sourceMappingURL=enum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/decorators/common/enum.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAmG5C,MAAM,UAAU,IAAI,CAAC,SAAgC,EAAE,GAAG,UAA6B;IACrF,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,UAAU,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {JSONSchema6Type} from \"json-schema\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\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 */\nexport function Enum(...enumValues: (JSONSchema6Type | any)[]): Function;\nexport function Enum(enumValue: JSONSchema6Type | any, ...enumValues: JSONSchema6Type[]) {\n return JsonEntityFn((store) => {\n store.itemSchema.enum(enumValue, ...enumValues);\n });\n}\n"]}
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/decorators/common/enum.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAG5C,SAAS,MAAM,CAAC,SAAgC,EAAE,GAAG,UAA6B;IAChF,OAAO,YAAY,CAAC,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;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,YAAY,CAAC,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,16 @@
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
+ /**
3
+ * Create a new custom formats validator
4
+ * @param name
5
+ * @param options
6
+ * @decorator
7
+ * @ajv
8
+ */
9
+ export function ErrorMsg(obj) {
10
+ return 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
+ store.parentSchema.customKey("errorMessage", { ...errorMessage, ...obj });
14
+ });
15
+ }
16
+ //# sourceMappingURL=errorMsg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorMsg.js","sourceRoot":"","sources":["../../../../src/decorators/common/errorMsg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,GAA2B;IAClD,OAAO,YAAY,CAAC,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","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,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { Maximum } from "./maximum.js";
2
3
  /**
3
4
  * The value of `exclusiveMaximum` MUST be number, representing an exclusive upper limit for a numeric instance.
@@ -66,8 +67,9 @@ import { Maximum } from "./maximum.js";
66
67
  * @swagger
67
68
  * @schema
68
69
  * @input
70
+ * @ajv-errors
69
71
  */
70
- export function ExclusiveMaximum(maximum, exclusiveMaximum = true) {
72
+ export const ExclusiveMaximum = withErrorMsg("exclusiveMaximum", (maximum, exclusiveMaximum = true) => {
71
73
  return Maximum(maximum, exclusiveMaximum);
72
- }
74
+ });
73
75
  //# sourceMappingURL=exclusiveMaximum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exclusiveMaximum.js","sourceRoot":"","sources":["../../../../src/decorators/common/exclusiveMaximum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,mBAA4B,IAAI;IAChF,OAAO,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import {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 */\nexport function ExclusiveMaximum(maximum: number, exclusiveMaximum: boolean = true) {\n return Maximum(maximum, exclusiveMaximum);\n}\n"]}
1
+ {"version":3,"file":"exclusiveMaximum.js","sourceRoot":"","sources":["../../../../src/decorators/common/exclusiveMaximum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC,kBAAkB,EAAE,CAAC,OAAe,EAAE,mBAA4B,IAAI,EAAE,EAAE;IACrH,OAAO,OAAO,CAAC,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,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { Minimum } from "./minimum.js";
2
3
  /**
3
4
  * The value of `exclusiveMinimum` MUST be number, representing an exclusive upper limit for a numeric instance.
@@ -66,8 +67,9 @@ import { Minimum } from "./minimum.js";
66
67
  * @swagger
67
68
  * @schema
68
69
  * @input
70
+ * @ajv-errors
69
71
  */
70
- export function ExclusiveMinimum(minimum, exclusiveMinimum = true) {
72
+ export const ExclusiveMinimum = withErrorMsg("exclusiveMinimum", (minimum, exclusiveMinimum = true) => {
71
73
  return Minimum(minimum, exclusiveMinimum);
72
- }
74
+ });
73
75
  //# sourceMappingURL=exclusiveMinimum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exclusiveMinimum.js","sourceRoot":"","sources":["../../../../src/decorators/common/exclusiveMinimum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,mBAA4B,IAAI;IAChF,OAAO,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import {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 */\nexport function ExclusiveMinimum(minimum: number, exclusiveMinimum: boolean = true) {\n return Minimum(minimum, exclusiveMinimum);\n}\n"]}
1
+ {"version":3,"file":"exclusiveMinimum.js","sourceRoot":"","sources":["../../../../src/decorators/common/exclusiveMinimum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC,kBAAkB,EAAE,CAAC,OAAe,EAAE,mBAA4B,IAAI,EAAE,EAAE;IACrH,OAAO,OAAO,CAAC,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"]}
@@ -1,4 +1,5 @@
1
1
  import { JsonFormatTypes } from "../../domain/JsonFormatTypes.js";
2
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
2
3
  import { JsonEntityFn } from "./jsonEntityFn.js";
3
4
  /**
4
5
  * The following formats are supported for string validation with `format` keyword:
@@ -72,12 +73,13 @@ import { JsonEntityFn } from "./jsonEntityFn.js";
72
73
  * @swagger
73
74
  * @schema
74
75
  * @input
76
+ * @ajv-errors
75
77
  */
76
- export function Format(format) {
78
+ export const Format = withErrorMsg("format", (format) => {
77
79
  return JsonEntityFn((store) => {
78
80
  store.itemSchema.format(format);
79
81
  });
80
- }
82
+ });
81
83
  /**
82
84
  * Apply an email validation on property.
83
85
  *
@@ -143,10 +145,11 @@ export function Format(format) {
143
145
  * @schema
144
146
  * @swagger
145
147
  * @input
148
+ * @ajv-errors
146
149
  */
147
- export function Email() {
150
+ export const Email = withErrorMsg("format", () => {
148
151
  return Format(JsonFormatTypes.EMAIL);
149
- }
152
+ });
150
153
  /**
151
154
  * Apply a date-time validation on property.
152
155
  *
@@ -209,10 +212,11 @@ export function Email() {
209
212
  * @parameter
210
213
  * @schema
211
214
  * @auto-map The data will be stored on the right place according to the type and collectionType (primitive or collection).
215
+ * @ajv-errors
212
216
  */
213
- export function DateTime() {
217
+ export const DateTime = withErrorMsg("format", () => {
214
218
  return Format(JsonFormatTypes.DATE_TIME);
215
- }
219
+ });
216
220
  /**
217
221
  * Apply a time validation on property.
218
222
  *
@@ -274,10 +278,11 @@ export function DateTime() {
274
278
  * @property
275
279
  * @parameter
276
280
  * @schema
281
+ * @ajv-errors
277
282
  */
278
- export function DateFormat() {
283
+ export const DateFormat = withErrorMsg("format", () => {
279
284
  return Format(JsonFormatTypes.DATE);
280
- }
285
+ });
281
286
  /**
282
287
  * Apply a time validation on property.
283
288
  *
@@ -339,10 +344,11 @@ export function DateFormat() {
339
344
  * @property
340
345
  * @parameter
341
346
  * @schema
347
+ * @ajv-errors
342
348
  */
343
- export function TimeFormat() {
349
+ export const TimeFormat = withErrorMsg("format", () => {
344
350
  return Format(JsonFormatTypes.TIME);
345
- }
351
+ });
346
352
  /**
347
353
  * Apply a uri validation on property.
348
354
  *
@@ -404,10 +410,11 @@ export function TimeFormat() {
404
410
  * @property
405
411
  * @parameter
406
412
  * @schema
413
+ * @ajv-errors
407
414
  */
408
- export function Uri() {
415
+ export const Uri = withErrorMsg("format", () => {
409
416
  return Format(JsonFormatTypes.URI);
410
- }
417
+ });
411
418
  /**
412
419
  * Apply a url validation on property.
413
420
  *
@@ -469,8 +476,9 @@ export function Uri() {
469
476
  * @property
470
477
  * @parameter
471
478
  * @schema
479
+ * @ajv-errors
472
480
  */
473
- export function Url() {
481
+ export const Url = withErrorMsg("format", () => {
474
482
  return Format(JsonFormatTypes.URL);
475
- }
483
+ });
476
484
  //# sourceMappingURL=format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../src/decorators/common/format.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,MAAM,UAAU,MAAM,CAAC,MAAkD;IACvE,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {ValueOf} from \"@tsed/core\";\nimport {JsonFormatTypes} from \"../../domain/JsonFormatTypes\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The following formats are supported for string validation with `format` keyword:\n *\n * - **date**: full-date according to [RFC3339](https://json-schema.org/latest/json-schema-validation.html#RFC3339).\n * - **time**: time with optional time-zone.\n * - **date-time**: date-time from the same source (time-zone is mandatory).\n * - **uri**: full uri with optional protocol.\n * - **email**: email address.\n * - **hostname**: host name according to [RFC1034](https://tools.ietf.org/html/rfc1034#section-3.1).\n * - **ipv4**: IP address v4.\n * - **ipv6**: IP address v6.\n * - **regex**: tests whether a string is a valid regular expression by passing it to RegExp constructor.\n *\n * ::: warning\n * For v6 user, use @@Format@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Format(\"email\")\n * property: string;\n * }\n * ```\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"email\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Format(\"email\")\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"email\"\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {string} format\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function Format(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) {\n return JsonEntityFn((store) => {\n store.itemSchema.format(format);\n });\n}\n\n/**\n * Apply an email validation on property.\n *\n * ::: warning\n * For v6 user, use @@Email@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Email()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"email\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Email()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"email\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @schema\n * @swagger\n * @input\n */\nexport function Email() {\n return Format(JsonFormatTypes.EMAIL);\n}\n\n/**\n * Apply a date-time validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @DateTime()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"date-time\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @DateTime()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"date-time\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n * @auto-map The data will be stored on the right place according to the type and collectionType (primitive or collection).\n */\nexport function DateTime() {\n return Format(JsonFormatTypes.DATE_TIME);\n}\n\n/**\n * Apply a time validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Time()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"time\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Time()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"time\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n */\nexport function DateFormat() {\n return Format(JsonFormatTypes.DATE);\n}\n\n/**\n * Apply a time validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @TimeFormat()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"time\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @TimeFormat()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"time\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n */\nexport function TimeFormat() {\n return Format(JsonFormatTypes.TIME);\n}\n\n/**\n * Apply a uri validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Uri()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"uri\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Uri()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"uri\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n */\nexport function Uri() {\n return Format(JsonFormatTypes.URI);\n}\n\n/**\n * Apply a url validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Url()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"url\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Url()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"url\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n */\nexport function Url() {\n return Format(JsonFormatTypes.URL);\n}\n"]}
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../src/decorators/common/format.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC,MAAkD,EAAE,EAAE;IAClG,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE;IAC/C,OAAO,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE;IAClD,OAAO,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpD,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpD,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE;IAC7C,OAAO,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE;IAC7C,OAAO,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC","sourcesContent":["import {ValueOf} from \"@tsed/core\";\nimport {JsonFormatTypes} from \"../../domain/JsonFormatTypes\";\nimport {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The following formats are supported for string validation with `format` keyword:\n *\n * - **date**: full-date according to [RFC3339](https://json-schema.org/latest/json-schema-validation.html#RFC3339).\n * - **time**: time with optional time-zone.\n * - **date-time**: date-time from the same source (time-zone is mandatory).\n * - **uri**: full uri with optional protocol.\n * - **email**: email address.\n * - **hostname**: host name according to [RFC1034](https://tools.ietf.org/html/rfc1034#section-3.1).\n * - **ipv4**: IP address v4.\n * - **ipv6**: IP address v6.\n * - **regex**: tests whether a string is a valid regular expression by passing it to RegExp constructor.\n *\n * ::: warning\n * For v6 user, use @@Format@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Format(\"email\")\n * property: string;\n * }\n * ```\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"email\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Format(\"email\")\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"email\"\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {string} format\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const Format = withErrorMsg(\"format\", (format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => {\n return JsonEntityFn((store) => {\n store.itemSchema.format(format);\n });\n});\n\n/**\n * Apply an email validation on property.\n *\n * ::: warning\n * For v6 user, use @@Email@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Email()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"email\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Email()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"email\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @schema\n * @swagger\n * @input\n * @ajv-errors\n */\nexport const Email = withErrorMsg(\"format\", () => {\n return Format(JsonFormatTypes.EMAIL);\n});\n\n/**\n * Apply a date-time validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @DateTime()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"date-time\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @DateTime()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"date-time\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n * @auto-map The data will be stored on the right place according to the type and collectionType (primitive or collection).\n * @ajv-errors\n */\nexport const DateTime = withErrorMsg(\"format\", () => {\n return Format(JsonFormatTypes.DATE_TIME);\n});\n\n/**\n * Apply a time validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Time()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"time\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Time()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"time\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n * @ajv-errors\n */\nexport const DateFormat = withErrorMsg(\"format\", () => {\n return Format(JsonFormatTypes.DATE);\n});\n\n/**\n * Apply a time validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @TimeFormat()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"time\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @TimeFormat()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"time\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n * @ajv-errors\n */\nexport const TimeFormat = withErrorMsg(\"format\", () => {\n return Format(JsonFormatTypes.TIME);\n});\n\n/**\n * Apply a uri validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Uri()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"uri\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Uri()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"uri\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n * @ajv-errors\n */\nexport const Uri = withErrorMsg(\"format\", () => {\n return Format(JsonFormatTypes.URI);\n});\n\n/**\n * Apply a url validation on property.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Url()\n * property: string;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"format\": \"url\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Url()\n * @CollectionOf(String)\n * property: string[];\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 * \"format\": \"url\"\n * }\n * }\n * }\n * }\n * ```\n *\n * > See [Format](api/common/jsonschema/schema) decorator.\n * @returns {Function}\n * @decorator\n * @validation\n * @property\n * @parameter\n * @schema\n * @ajv-errors\n */\nexport const Url = withErrorMsg(\"format\", () => {\n return Format(JsonFormatTypes.URL);\n});\n"]}
@@ -1,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "./jsonEntityFn.js";
2
3
  /**
3
4
  * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
@@ -73,13 +74,14 @@ import { JsonEntityFn } from "./jsonEntityFn.js";
73
74
  * @swagger
74
75
  * @schema
75
76
  * @input
77
+ * @ajv-errors
76
78
  */
77
- export function MaxLength(maxLength) {
79
+ export const MaxLength = withErrorMsg("maxLength", (maxLength) => {
78
80
  if (maxLength < 0) {
79
81
  throw new Error("The value of maxLength MUST be a non-negative integer.");
80
82
  }
81
83
  return JsonEntityFn((store) => {
82
84
  store.itemSchema.maxLength(maxLength);
83
85
  });
84
- }
86
+ });
85
87
  //# sourceMappingURL=maxLength.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"maxLength.js","sourceRoot":"","sources":["../../../../src/decorators/common/maxLength.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,MAAM,UAAU,SAAS,CAAC,SAAiB;IACzC,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.\n *\n * The length of a string instance is defined as the number of its characters as defined by [RFC 7159](http://json-schema.org/latest/json-schema-validation.html#RFC7159).\n *\n * ::: warning\n * The value of maxLength 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 @@MaxLength@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @MaxLength(10)\n * property: number;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"maxLength\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @MaxLength(10)\n * @CollectionOf(String)\n * property: string[];\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 * \"maxLength\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} maxLength The maximum length allowed\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function MaxLength(maxLength: number) {\n if (maxLength < 0) {\n throw new Error(\"The value of maxLength MUST be a non-negative integer.\");\n }\n\n return JsonEntityFn((store) => {\n store.itemSchema.maxLength(maxLength);\n });\n}\n"]}
1
+ {"version":3,"file":"maxLength.js","sourceRoot":"","sources":["../../../../src/decorators/common/maxLength.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,SAAiB,EAAE,EAAE;IACvE,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.\n *\n * The length of a string instance is defined as the number of its characters as defined by [RFC 7159](http://json-schema.org/latest/json-schema-validation.html#RFC7159).\n *\n * ::: warning\n * The value of maxLength 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 @@MaxLength@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @MaxLength(10)\n * property: number;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"maxLength\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @MaxLength(10)\n * @CollectionOf(String)\n * property: string[];\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 * \"maxLength\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} maxLength The maximum length allowed\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const MaxLength = withErrorMsg(\"maxLength\", (maxLength: number) => {\n if (maxLength < 0) {\n throw new Error(\"The value of maxLength MUST be a non-negative integer.\");\n }\n\n return JsonEntityFn((store) => {\n store.itemSchema.maxLength(maxLength);\n });\n});\n"]}
@@ -1,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "./jsonEntityFn.js";
2
3
  /**
3
4
  * The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.
@@ -66,12 +67,13 @@ import { JsonEntityFn } from "./jsonEntityFn.js";
66
67
  * @swagger
67
68
  * @schema
68
69
  * @input
70
+ * @ajv-errors
69
71
  */
70
- export function Maximum(maximum, exclusive = false) {
72
+ export const Maximum = withErrorMsg("maximum", (maximum, exclusive = false) => {
71
73
  return JsonEntityFn((store) => {
72
74
  exclusive ? store.itemSchema.exclusiveMaximum(maximum) : store.itemSchema.maximum(maximum);
73
75
  });
74
- }
76
+ });
75
77
  /**
76
78
  * The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.
77
79
  *
@@ -140,7 +142,5 @@ export function Maximum(maximum, exclusive = false) {
140
142
  * @schema
141
143
  * @input
142
144
  */
143
- export function Max(maximum, exclusive = false) {
144
- return Maximum(maximum, exclusive);
145
- }
145
+ export const Max = Maximum;
146
146
  //# sourceMappingURL=maximum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"maximum.js","sourceRoot":"","sources":["../../../../src/decorators/common/maximum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe,EAAE,YAAqB,KAAK;IACjE,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACL,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,YAAqB,KAAK;IAC7D,OAAO,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to `maximum`.\n *\n * ::: warning\n * For v6 user, use @@Maximum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Maximum(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 * \"maximum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Maximum(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 * \"maximum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} maximum The maximum value allowed\n * @param {boolean} exclusive Same effect as ExclusiveMaximum decorator.\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function Maximum(maximum: number, exclusive: boolean = false) {\n return JsonEntityFn((store) => {\n exclusive ? store.itemSchema.exclusiveMaximum(maximum) : store.itemSchema.maximum(maximum);\n });\n}\n/**\n * The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to `maximum`.\n *\n * ::: warning\n * For v6 user, use @@Maximum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Max(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 * \"maximum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Max(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 * \"maximum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} maximum The maximum value allowed\n * @param {boolean} exclusive Same effect as ExclusiveMaximum decorator.\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function Max(maximum: number, exclusive: boolean = false) {\n return Maximum(maximum, exclusive);\n}\n"]}
1
+ {"version":3,"file":"maximum.js","sourceRoot":"","sources":["../../../../src/decorators/common/maximum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC,OAAe,EAAE,YAAqB,KAAK,EAAE,EAAE;IAC7F,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to `maximum`.\n *\n * ::: warning\n * For v6 user, use @@Maximum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Maximum(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 * \"maximum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Maximum(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 * \"maximum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} maximum The maximum value allowed\n * @param {boolean} exclusive Same effect as ExclusiveMaximum decorator.\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const Maximum = withErrorMsg(\"maximum\", (maximum: number, exclusive: boolean = false) => {\n return JsonEntityFn((store) => {\n exclusive ? store.itemSchema.exclusiveMaximum(maximum) : store.itemSchema.maximum(maximum);\n });\n});\n/**\n * The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to `maximum`.\n *\n * ::: warning\n * For v6 user, use @@Maximum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Max(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 * \"maximum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Max(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 * \"maximum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} maximum The maximum value allowed\n * @param {boolean} exclusive Same effect as ExclusiveMaximum decorator.\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport const Max = Maximum;\n"]}
@@ -1,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "./jsonEntityFn.js";
2
3
  /**
3
4
  *
@@ -74,13 +75,14 @@ import { JsonEntityFn } from "./jsonEntityFn.js";
74
75
  * @swagger
75
76
  * @schema
76
77
  * @input
78
+ * @ajv-errors
77
79
  */
78
- export function MinLength(minLength) {
80
+ export const MinLength = withErrorMsg("minLength", (minLength) => {
79
81
  if (minLength < 0) {
80
82
  throw new Error("The value of minLength MUST be a non-negative integer.");
81
83
  }
82
84
  return JsonEntityFn((store) => {
83
85
  store.itemSchema.minLength(minLength);
84
86
  });
85
- }
87
+ });
86
88
  //# sourceMappingURL=minLength.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"minLength.js","sourceRoot":"","sources":["../../../../src/decorators/common/minLength.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,MAAM,UAAU,SAAS,CAAC,SAAiB;IACzC,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n *\n * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.\n *\n * The length of a string instance is defined as the number of its characters as defined by [RFC 7159](http://json-schema.org/latest/json-schema-validation.html#RFC7159).\n *\n * ::: warning\n * The value of minLength 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 @@MinLength@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @MinLength(10)\n * property: number;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"maxLength\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @MinLength(10)\n * @CollectionOf(String)\n * property: string[];\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 * \"minLength\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} minLength\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function MinLength(minLength: number) {\n if (minLength < 0) {\n throw new Error(\"The value of minLength MUST be a non-negative integer.\");\n }\n\n return JsonEntityFn((store) => {\n store.itemSchema.minLength(minLength);\n });\n}\n"]}
1
+ {"version":3,"file":"minLength.js","sourceRoot":"","sources":["../../../../src/decorators/common/minLength.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,SAAiB,EAAE,EAAE;IACvE,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n *\n * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.\n *\n * The length of a string instance is defined as the number of its characters as defined by [RFC 7159](http://json-schema.org/latest/json-schema-validation.html#RFC7159).\n *\n * ::: warning\n * The value of minLength 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 @@MinLength@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @MinLength(10)\n * property: number;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"maxLength\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @MinLength(10)\n * @CollectionOf(String)\n * property: string[];\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 * \"minLength\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} minLength\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const MinLength = withErrorMsg(\"minLength\", (minLength: number) => {\n if (minLength < 0) {\n throw new Error(\"The value of minLength MUST be a non-negative integer.\");\n }\n\n return JsonEntityFn((store) => {\n store.itemSchema.minLength(minLength);\n });\n});\n"]}
@@ -1,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "./jsonEntityFn.js";
2
3
  /**
3
4
  * The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.
@@ -67,12 +68,13 @@ import { JsonEntityFn } from "./jsonEntityFn.js";
67
68
  * @swagger
68
69
  * @schema
69
70
  * @input
71
+ * @ajv-errors
70
72
  */
71
- export function Minimum(minimum, exclusive = false) {
73
+ export const Minimum = withErrorMsg("minimum", (minimum, exclusive = false) => {
72
74
  return JsonEntityFn((store) => {
73
75
  exclusive ? store.itemSchema.exclusiveMinimum(minimum) : store.itemSchema.minimum(minimum);
74
76
  });
75
- }
77
+ });
76
78
  /**
77
79
  * The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.
78
80
  *
@@ -138,7 +140,5 @@ export function Minimum(minimum, exclusive = false) {
138
140
  * @schema
139
141
  * @input
140
142
  */
141
- export function Min(minimum, exclusive = false) {
142
- return Minimum(minimum, exclusive);
143
- }
143
+ export const Min = Minimum;
144
144
  //# sourceMappingURL=minimum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"minimum.js","sourceRoot":"","sources":["../../../../src/decorators/common/minimum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe,EAAE,YAAqB,KAAK;IACjE,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,YAAqB,KAAK;IAC7D,OAAO,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to `minimum`.\n *\n * ::: warning\n * This decorator will be removed in v7.\n * For v6 user, use @@Minimum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Minimum(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 * \"minimum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Minimum(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 * \"minimum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} minimum The minimum value allowed\n * @param {boolean} exclusive\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function Minimum(minimum: number, exclusive: boolean = false) {\n return JsonEntityFn((store) => {\n exclusive ? store.itemSchema.exclusiveMinimum(minimum) : store.itemSchema.minimum(minimum);\n });\n}\n\n/**\n * The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to `minimum`.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Min(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 * \"minimum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Min(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 * \"minimum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @alias Minimum\n * @param minimum The minimum value allowed\n * @param exclusive\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function Min(minimum: number, exclusive: boolean = false) {\n return Minimum(minimum, exclusive);\n}\n"]}
1
+ {"version":3,"file":"minimum.js","sourceRoot":"","sources":["../../../../src/decorators/common/minimum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC,OAAe,EAAE,YAAqB,KAAK,EAAE,EAAE;IAC7F,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to `minimum`.\n *\n * ::: warning\n * This decorator will be removed in v7.\n * For v6 user, use @@Minimum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Minimum(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 * \"minimum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Minimum(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 * \"minimum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} minimum The minimum value allowed\n * @param {boolean} exclusive\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const Minimum = withErrorMsg(\"minimum\", (minimum: number, exclusive: boolean = false) => {\n return JsonEntityFn((store) => {\n exclusive ? store.itemSchema.exclusiveMinimum(minimum) : store.itemSchema.minimum(minimum);\n });\n});\n\n/**\n * The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.\n *\n * If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to `minimum`.\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Min(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 * \"minimum\": 10\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Min(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 * \"minimum\": 10\n * }\n * }\n * }\n * }\n * ```\n *\n * @alias Minimum\n * @param minimum The minimum value allowed\n * @param exclusive\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport const Min = Minimum;\n"]}
@@ -1,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "./jsonEntityFn.js";
2
3
  /**
3
4
  * A numeric instance is valid only if division by this keyword's value results in an integer.
@@ -65,13 +66,14 @@ import { JsonEntityFn } from "./jsonEntityFn.js";
65
66
  * @swagger
66
67
  * @schema
67
68
  * @input
69
+ * @ajv-errors
68
70
  */
69
- export function MultipleOf(multipleOf) {
71
+ export const MultipleOf = withErrorMsg("multipleOf", (multipleOf) => {
70
72
  if (multipleOf <= 0) {
71
73
  throw new Error("The value of multipleOf MUST be a number, strictly greater than 0.");
72
74
  }
73
75
  return JsonEntityFn((store) => {
74
76
  store.itemSchema.multipleOf(multipleOf);
75
77
  });
76
- }
78
+ });
77
79
  //# sourceMappingURL=multipleOf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"multipleOf.js","sourceRoot":"","sources":["../../../../src/decorators/common/multipleOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,MAAM,UAAU,UAAU,CAAC,UAAkB;IAC3C,IAAI,UAAU,IAAI,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;KACvF;IAED,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * A numeric instance is valid only if division by this keyword's value results in an integer.\n *\n * ::: warning\n * The value of `multipleOf` MUST be a number, strictly greater than 0.\n * :::\n *\n * ::: warning\n * For v6 user, use @@MultipleOf@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @MultipleOf(2)\n * property: Number;\n * }\n * ```\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"number\",\n * \"multipleOf\": 2\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @CollectionOf(number)\n * @MultipleOf(2)\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 * \"multipleOf\": 2\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} multipleOf The multiple value allowed\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function MultipleOf(multipleOf: number) {\n if (multipleOf <= 0) {\n throw new Error(\"The value of multipleOf MUST be a number, strictly greater than 0.\");\n }\n\n return JsonEntityFn((store) => {\n store.itemSchema.multipleOf(multipleOf);\n });\n}\n"]}
1
+ {"version":3,"file":"multipleOf.js","sourceRoot":"","sources":["../../../../src/decorators/common/multipleOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC,YAAY,EAAE,CAAC,UAAkB,EAAE,EAAE;IAC1E,IAAI,UAAU,IAAI,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;KACvF;IAED,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * A numeric instance is valid only if division by this keyword's value results in an integer.\n *\n * ::: warning\n * The value of `multipleOf` MUST be a number, strictly greater than 0.\n * :::\n *\n * ::: warning\n * For v6 user, use @@MultipleOf@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @MultipleOf(2)\n * property: Number;\n * }\n * ```\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"number\",\n * \"multipleOf\": 2\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @CollectionOf(number)\n * @MultipleOf(2)\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 * \"multipleOf\": 2\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {number} multipleOf The multiple value allowed\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const MultipleOf = withErrorMsg(\"multipleOf\", (multipleOf: number) => {\n if (multipleOf <= 0) {\n throw new Error(\"The value of multipleOf MUST be a number, strictly greater than 0.\");\n }\n\n return JsonEntityFn((store) => {\n store.itemSchema.multipleOf(multipleOf);\n });\n});\n"]}
@@ -1,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "./jsonEntityFn.js";
2
3
  /**
3
4
  * The pattern and Pattern Properties keywords use regular expressions to express constraints.
@@ -90,10 +91,11 @@ import { JsonEntityFn } from "./jsonEntityFn.js";
90
91
  * @swagger
91
92
  * @schema
92
93
  * @input
94
+ * @ajv-errors
93
95
  */
94
- export function Pattern(pattern) {
96
+ export const Pattern = withErrorMsg("pattern", (pattern) => {
95
97
  return JsonEntityFn((store) => {
96
98
  store.itemSchema.pattern(pattern);
97
99
  });
98
- }
100
+ });
99
101
  //# sourceMappingURL=pattern.js.map