@tsed/schema 7.10.1 → 7.12.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 (108) 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/index.js +4 -0
  42. package/lib/cjs/index.js.map +1 -1
  43. package/lib/cjs/utils/withErrorMsg.js +18 -0
  44. package/lib/cjs/utils/withErrorMsg.js.map +1 -0
  45. package/lib/esm/decorators/collections/maxItems.js +4 -2
  46. package/lib/esm/decorators/collections/maxItems.js.map +1 -1
  47. package/lib/esm/decorators/collections/maxProperties.js +4 -2
  48. package/lib/esm/decorators/collections/maxProperties.js.map +1 -1
  49. package/lib/esm/decorators/collections/minItems.js +4 -2
  50. package/lib/esm/decorators/collections/minItems.js.map +1 -1
  51. package/lib/esm/decorators/collections/minProperties.js +4 -2
  52. package/lib/esm/decorators/collections/minProperties.js.map +1 -1
  53. package/lib/esm/decorators/collections/uniqueItems.js +4 -2
  54. package/lib/esm/decorators/collections/uniqueItems.js.map +1 -1
  55. package/lib/esm/decorators/common/defaultMsg.js +37 -0
  56. package/lib/esm/decorators/common/defaultMsg.js.map +1 -0
  57. package/lib/esm/decorators/common/enum.js +100 -1
  58. package/lib/esm/decorators/common/enum.js.map +1 -1
  59. package/lib/esm/decorators/common/errorMsg.js +16 -0
  60. package/lib/esm/decorators/common/errorMsg.js.map +1 -0
  61. package/lib/esm/decorators/common/exclusiveMaximum.js +4 -2
  62. package/lib/esm/decorators/common/exclusiveMaximum.js.map +1 -1
  63. package/lib/esm/decorators/common/exclusiveMinimum.js +4 -2
  64. package/lib/esm/decorators/common/exclusiveMinimum.js.map +1 -1
  65. package/lib/esm/decorators/common/format.js +22 -14
  66. package/lib/esm/decorators/common/format.js.map +1 -1
  67. package/lib/esm/decorators/common/maxLength.js +4 -2
  68. package/lib/esm/decorators/common/maxLength.js.map +1 -1
  69. package/lib/esm/decorators/common/maximum.js +5 -5
  70. package/lib/esm/decorators/common/maximum.js.map +1 -1
  71. package/lib/esm/decorators/common/minLength.js +4 -2
  72. package/lib/esm/decorators/common/minLength.js.map +1 -1
  73. package/lib/esm/decorators/common/minimum.js +5 -5
  74. package/lib/esm/decorators/common/minimum.js.map +1 -1
  75. package/lib/esm/decorators/common/multipleOf.js +4 -2
  76. package/lib/esm/decorators/common/multipleOf.js.map +1 -1
  77. package/lib/esm/decorators/common/pattern.js +4 -2
  78. package/lib/esm/decorators/common/pattern.js.map +1 -1
  79. package/lib/esm/decorators/common/required.js +3 -2
  80. package/lib/esm/decorators/common/required.js.map +1 -1
  81. package/lib/esm/decorators/common/typeError.js +14 -0
  82. package/lib/esm/decorators/common/typeError.js.map +1 -0
  83. package/lib/esm/index.js +4 -0
  84. package/lib/esm/index.js.map +1 -1
  85. package/lib/esm/utils/withErrorMsg.js +14 -0
  86. package/lib/esm/utils/withErrorMsg.js.map +1 -0
  87. package/lib/types/decorators/collections/maxItems.d.ts +2 -1
  88. package/lib/types/decorators/collections/maxProperties.d.ts +2 -1
  89. package/lib/types/decorators/collections/minItems.d.ts +2 -1
  90. package/lib/types/decorators/collections/minProperties.d.ts +2 -1
  91. package/lib/types/decorators/collections/uniqueItems.d.ts +2 -1
  92. package/lib/types/decorators/common/defaultMsg.d.ts +32 -0
  93. package/lib/types/decorators/common/enum.d.ts +4 -1
  94. package/lib/types/decorators/common/errorMsg.d.ts +8 -0
  95. package/lib/types/decorators/common/exclusiveMaximum.d.ts +2 -1
  96. package/lib/types/decorators/common/exclusiveMinimum.d.ts +2 -1
  97. package/lib/types/decorators/common/format.d.ts +14 -7
  98. package/lib/types/decorators/common/maxLength.d.ts +2 -1
  99. package/lib/types/decorators/common/maximum.d.ts +3 -2
  100. package/lib/types/decorators/common/minLength.d.ts +2 -1
  101. package/lib/types/decorators/common/minimum.d.ts +3 -2
  102. package/lib/types/decorators/common/multipleOf.d.ts +2 -1
  103. package/lib/types/decorators/common/pattern.d.ts +2 -1
  104. package/lib/types/decorators/common/required.d.ts +1 -1
  105. package/lib/types/decorators/common/typeError.d.ts +8 -0
  106. package/lib/types/index.d.ts +4 -0
  107. package/lib/types/utils/withErrorMsg.d.ts +6 -0
  108. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../src/decorators/common/format.ts"],"names":[],"mappings":";;;AACA,kEAA6D;AAC7D,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,SAAgB,MAAM,CAAC,MAAkD;IACvE,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,wBAIC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,SAAgB,KAAK;IACnB,OAAO,MAAM,CAAC,iCAAe,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAFD,sBAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,SAAgB,QAAQ;IACtB,OAAO,MAAM,CAAC,iCAAe,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAFD,4BAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,SAAgB,UAAU;IACxB,OAAO,MAAM,CAAC,iCAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAFD,gCAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,SAAgB,UAAU;IACxB,OAAO,MAAM,CAAC,iCAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAFD,gCAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,SAAgB,GAAG;IACjB,OAAO,MAAM,CAAC,iCAAe,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAFD,kBAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,SAAgB,GAAG;IACjB,OAAO,MAAM,CAAC,iCAAe,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAFD,kBAEC","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,kEAA6D;AAC7D,2DAAsD;AACtD,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACU,QAAA,MAAM,GAAG,IAAA,2BAAY,EAAC,QAAQ,EAAE,CAAC,MAAkD,EAAE,EAAE;IAClG,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACU,QAAA,KAAK,GAAG,IAAA,2BAAY,EAAC,QAAQ,EAAE,GAAG,EAAE;IAC/C,OAAO,IAAA,cAAM,EAAC,iCAAe,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACU,QAAA,QAAQ,GAAG,IAAA,2BAAY,EAAC,QAAQ,EAAE,GAAG,EAAE;IAClD,OAAO,IAAA,cAAM,EAAC,iCAAe,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACU,QAAA,UAAU,GAAG,IAAA,2BAAY,EAAC,QAAQ,EAAE,GAAG,EAAE;IACpD,OAAO,IAAA,cAAM,EAAC,iCAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACU,QAAA,UAAU,GAAG,IAAA,2BAAY,EAAC,QAAQ,EAAE,GAAG,EAAE;IACpD,OAAO,IAAA,cAAM,EAAC,iCAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACU,QAAA,GAAG,GAAG,IAAA,2BAAY,EAAC,QAAQ,EAAE,GAAG,EAAE;IAC7C,OAAO,IAAA,cAAM,EAAC,iCAAe,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACU,QAAA,GAAG,GAAG,IAAA,2BAAY,EAAC,QAAQ,EAAE,GAAG,EAAE;IAC7C,OAAO,IAAA,cAAM,EAAC,iCAAe,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MaxLength = void 0;
4
+ const withErrorMsg_1 = require("../../utils/withErrorMsg");
4
5
  const jsonEntityFn_1 = require("./jsonEntityFn");
5
6
  /**
6
7
  * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
@@ -76,14 +77,14 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
76
77
  * @swagger
77
78
  * @schema
78
79
  * @input
80
+ * @ajv-errors
79
81
  */
80
- function MaxLength(maxLength) {
82
+ exports.MaxLength = (0, withErrorMsg_1.withErrorMsg)("maxLength", (maxLength) => {
81
83
  if (maxLength < 0) {
82
84
  throw new Error("The value of maxLength MUST be a non-negative integer.");
83
85
  }
84
86
  return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
85
87
  store.itemSchema.maxLength(maxLength);
86
88
  });
87
- }
88
- exports.MaxLength = MaxLength;
89
+ });
89
90
  //# sourceMappingURL=maxLength.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"maxLength.js","sourceRoot":"","sources":["../../../../src/decorators/common/maxLength.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,SAAgB,SAAS,CAAC,SAAiB;IACzC,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC;AARD,8BAQC","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,2DAAsD;AACtD,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACU,QAAA,SAAS,GAAG,IAAA,2BAAY,EAAC,WAAW,EAAE,CAAC,SAAiB,EAAE,EAAE;IACvE,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,IAAA,2BAAY,EAAC,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Max = exports.Maximum = void 0;
4
+ const withErrorMsg_1 = require("../../utils/withErrorMsg");
4
5
  const jsonEntityFn_1 = require("./jsonEntityFn");
5
6
  /**
6
7
  * The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.
@@ -69,13 +70,13 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
69
70
  * @swagger
70
71
  * @schema
71
72
  * @input
73
+ * @ajv-errors
72
74
  */
73
- function Maximum(maximum, exclusive = false) {
75
+ exports.Maximum = (0, withErrorMsg_1.withErrorMsg)("maximum", (maximum, exclusive = false) => {
74
76
  return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
75
77
  exclusive ? store.itemSchema.exclusiveMaximum(maximum) : store.itemSchema.maximum(maximum);
76
78
  });
77
- }
78
- exports.Maximum = Maximum;
79
+ });
79
80
  /**
80
81
  * The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.
81
82
  *
@@ -144,8 +145,5 @@ exports.Maximum = Maximum;
144
145
  * @schema
145
146
  * @input
146
147
  */
147
- function Max(maximum, exclusive = false) {
148
- return Maximum(maximum, exclusive);
149
- }
150
- exports.Max = Max;
148
+ exports.Max = exports.Maximum;
151
149
  //# sourceMappingURL=maximum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"maximum.js","sourceRoot":"","sources":["../../../../src/decorators/common/maximum.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,SAAgB,OAAO,CAAC,OAAe,EAAE,YAAqB,KAAK;IACjE,OAAO,IAAA,2BAAY,EAAC,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;AAJD,0BAIC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,SAAgB,GAAG,CAAC,OAAe,EAAE,YAAqB,KAAK;IAC7D,OAAO,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACrC,CAAC;AAFD,kBAEC","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,2DAAsD;AACtD,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACU,QAAA,OAAO,GAAG,IAAA,2BAAY,EAAC,SAAS,EAAE,CAAC,OAAe,EAAE,YAAqB,KAAK,EAAE,EAAE;IAC7F,OAAO,IAAA,2BAAY,EAAC,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;AACU,QAAA,GAAG,GAAG,eAAO,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MinLength = void 0;
4
+ const withErrorMsg_1 = require("../../utils/withErrorMsg");
4
5
  const jsonEntityFn_1 = require("./jsonEntityFn");
5
6
  /**
6
7
  *
@@ -77,14 +78,14 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
77
78
  * @swagger
78
79
  * @schema
79
80
  * @input
81
+ * @ajv-errors
80
82
  */
81
- function MinLength(minLength) {
83
+ exports.MinLength = (0, withErrorMsg_1.withErrorMsg)("minLength", (minLength) => {
82
84
  if (minLength < 0) {
83
85
  throw new Error("The value of minLength MUST be a non-negative integer.");
84
86
  }
85
87
  return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
86
88
  store.itemSchema.minLength(minLength);
87
89
  });
88
- }
89
- exports.MinLength = MinLength;
90
+ });
90
91
  //# sourceMappingURL=minLength.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"minLength.js","sourceRoot":"","sources":["../../../../src/decorators/common/minLength.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,SAAgB,SAAS,CAAC,SAAiB;IACzC,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC;AARD,8BAQC","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,2DAAsD;AACtD,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACU,QAAA,SAAS,GAAG,IAAA,2BAAY,EAAC,WAAW,EAAE,CAAC,SAAiB,EAAE,EAAE;IACvE,IAAI,SAAS,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,IAAA,2BAAY,EAAC,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Min = exports.Minimum = void 0;
4
+ const withErrorMsg_1 = require("../../utils/withErrorMsg");
4
5
  const jsonEntityFn_1 = require("./jsonEntityFn");
5
6
  /**
6
7
  * The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.
@@ -70,13 +71,13 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
70
71
  * @swagger
71
72
  * @schema
72
73
  * @input
74
+ * @ajv-errors
73
75
  */
74
- function Minimum(minimum, exclusive = false) {
76
+ exports.Minimum = (0, withErrorMsg_1.withErrorMsg)("minimum", (minimum, exclusive = false) => {
75
77
  return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
76
78
  exclusive ? store.itemSchema.exclusiveMinimum(minimum) : store.itemSchema.minimum(minimum);
77
79
  });
78
- }
79
- exports.Minimum = Minimum;
80
+ });
80
81
  /**
81
82
  * The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.
82
83
  *
@@ -142,8 +143,5 @@ exports.Minimum = Minimum;
142
143
  * @schema
143
144
  * @input
144
145
  */
145
- function Min(minimum, exclusive = false) {
146
- return Minimum(minimum, exclusive);
147
- }
148
- exports.Min = Min;
146
+ exports.Min = exports.Minimum;
149
147
  //# sourceMappingURL=minimum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"minimum.js","sourceRoot":"","sources":["../../../../src/decorators/common/minimum.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,SAAgB,OAAO,CAAC,OAAe,EAAE,YAAqB,KAAK;IACjE,OAAO,IAAA,2BAAY,EAAC,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;AAJD,0BAIC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,SAAgB,GAAG,CAAC,OAAe,EAAE,YAAqB,KAAK;IAC7D,OAAO,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACrC,CAAC;AAFD,kBAEC","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,2DAAsD;AACtD,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACU,QAAA,OAAO,GAAG,IAAA,2BAAY,EAAC,SAAS,EAAE,CAAC,OAAe,EAAE,YAAqB,KAAK,EAAE,EAAE;IAC7F,OAAO,IAAA,2BAAY,EAAC,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;AACU,QAAA,GAAG,GAAG,eAAO,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MultipleOf = void 0;
4
+ const withErrorMsg_1 = require("../../utils/withErrorMsg");
4
5
  const jsonEntityFn_1 = require("./jsonEntityFn");
5
6
  /**
6
7
  * A numeric instance is valid only if division by this keyword's value results in an integer.
@@ -68,14 +69,14 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
68
69
  * @swagger
69
70
  * @schema
70
71
  * @input
72
+ * @ajv-errors
71
73
  */
72
- function MultipleOf(multipleOf) {
74
+ exports.MultipleOf = (0, withErrorMsg_1.withErrorMsg)("multipleOf", (multipleOf) => {
73
75
  if (multipleOf <= 0) {
74
76
  throw new Error("The value of multipleOf MUST be a number, strictly greater than 0.");
75
77
  }
76
78
  return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
77
79
  store.itemSchema.multipleOf(multipleOf);
78
80
  });
79
- }
80
- exports.MultipleOf = MultipleOf;
81
+ });
81
82
  //# sourceMappingURL=multipleOf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"multipleOf.js","sourceRoot":"","sources":["../../../../src/decorators/common/multipleOf.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,SAAgB,UAAU,CAAC,UAAkB;IAC3C,IAAI,UAAU,IAAI,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;KACvF;IAED,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC;AARD,gCAQC","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,2DAAsD;AACtD,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACU,QAAA,UAAU,GAAG,IAAA,2BAAY,EAAC,YAAY,EAAE,CAAC,UAAkB,EAAE,EAAE;IAC1E,IAAI,UAAU,IAAI,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;KACvF;IAED,OAAO,IAAA,2BAAY,EAAC,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Pattern = void 0;
4
+ const withErrorMsg_1 = require("../../utils/withErrorMsg");
4
5
  const jsonEntityFn_1 = require("./jsonEntityFn");
5
6
  /**
6
7
  * The pattern and Pattern Properties keywords use regular expressions to express constraints.
@@ -93,11 +94,11 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
93
94
  * @swagger
94
95
  * @schema
95
96
  * @input
97
+ * @ajv-errors
96
98
  */
97
- function Pattern(pattern) {
99
+ exports.Pattern = (0, withErrorMsg_1.withErrorMsg)("pattern", (pattern) => {
98
100
  return (0, jsonEntityFn_1.JsonEntityFn)((store) => {
99
101
  store.itemSchema.pattern(pattern);
100
102
  });
101
- }
102
- exports.Pattern = Pattern;
103
+ });
103
104
  //# sourceMappingURL=pattern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../../../src/decorators/common/pattern.ts"],"names":[],"mappings":";;;AACA,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,SAAgB,OAAO,CAAC,OAAwB;IAC9C,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAsB,EAAE,EAAE;QAC7C,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,0BAIC","sourcesContent":["import {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The pattern and Pattern Properties keywords use regular expressions to express constraints.\n * The regular expression syntax used is from JavaScript (ECMA 262, specifically). However, that complete syntax is not widely supported, therefore it is recommended that you stick to the subset of that syntax described below.\n *\n * ::: warning\n * For v6 user, use @@Pattern@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * A single unicode character (other than the special characters below) matches itself.\n *\n * * `^`: Matches only at the beginning of the string.\n * * `$`: Matches only at the end of the string.\n * * `(...)`: Group a series of regular expressions into a single regular expression.\n * * `|`: Matches either the regular expression preceding or following the | symbol.\n * * `[abc]`: Matches any of the characters inside the square brackets.\n * * `[a-z]`: Matches the range of characters.\n * * `[^abc]`: Matches any character not listed.\n * * `[^a-z]`: Matches any character outside of the range.\n * * `+`: Matches one or more repetitions of the preceding regular expression.\n * * `*`: Matches zero or more repetitions of the preceding regular expression.\n * * `?`: Matches zero or one repetitions of the preceding regular expression.\n * * `+?`, *?`, ??`: The `*`, `+`, and `?` qualifiers are all greedy; they match as much text as possible. Sometimes this behavior isn’t desired and you want to match as few characters as possible.\n * * `{x}`: Match exactly x occurrences of the preceding regular expression.\n * * `{x,y}`: Match at least x and at most y occurrences of the preceding regular expression.\n * * `{x,}`: Match x occurrences or more of the preceding regular expression.\n * * `{x}?`, {x,y}?, {x,}?`: Lazy versions of the above expressions.\n *\n * ## Example\n *\n * ```typescript\n * class Model {\n * @Pattern(\"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\")\n * @Pattern(/^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$/)\n * property: string;\n * }\n * ```\n *\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Pattern(/^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$/)\n * property: string;\n * }\n * ```\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @CollectionOf(string)\n * @Pattern(/^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$/)\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 * \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {string} pattern\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function Pattern(pattern: string | RegExp) {\n return JsonEntityFn((store: JsonEntityStore) => {\n store.itemSchema.pattern(pattern);\n });\n}\n"]}
1
+ {"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../../../src/decorators/common/pattern.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AACtD,iDAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACU,QAAA,OAAO,GAAG,IAAA,2BAAY,EAAC,SAAS,EAAE,CAAC,OAAwB,EAAE,EAAE;IAC1E,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAsB,EAAE,EAAE;QAC7C,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The pattern and Pattern Properties keywords use regular expressions to express constraints.\n * The regular expression syntax used is from JavaScript (ECMA 262, specifically). However, that complete syntax is not widely supported, therefore it is recommended that you stick to the subset of that syntax described below.\n *\n * ::: warning\n * For v6 user, use @@Pattern@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * A single unicode character (other than the special characters below) matches itself.\n *\n * * `^`: Matches only at the beginning of the string.\n * * `$`: Matches only at the end of the string.\n * * `(...)`: Group a series of regular expressions into a single regular expression.\n * * `|`: Matches either the regular expression preceding or following the | symbol.\n * * `[abc]`: Matches any of the characters inside the square brackets.\n * * `[a-z]`: Matches the range of characters.\n * * `[^abc]`: Matches any character not listed.\n * * `[^a-z]`: Matches any character outside of the range.\n * * `+`: Matches one or more repetitions of the preceding regular expression.\n * * `*`: Matches zero or more repetitions of the preceding regular expression.\n * * `?`: Matches zero or one repetitions of the preceding regular expression.\n * * `+?`, *?`, ??`: The `*`, `+`, and `?` qualifiers are all greedy; they match as much text as possible. Sometimes this behavior isn’t desired and you want to match as few characters as possible.\n * * `{x}`: Match exactly x occurrences of the preceding regular expression.\n * * `{x,y}`: Match at least x and at most y occurrences of the preceding regular expression.\n * * `{x,}`: Match x occurrences or more of the preceding regular expression.\n * * `{x}?`, {x,y}?, {x,}?`: Lazy versions of the above expressions.\n *\n * ## Example\n *\n * ```typescript\n * class Model {\n * @Pattern(\"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\")\n * @Pattern(/^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$/)\n * property: string;\n * }\n * ```\n *\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Pattern(/^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$/)\n * property: string;\n * }\n * ```\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @CollectionOf(string)\n * @Pattern(/^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$/)\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 * \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\n * }\n * }\n * }\n * }\n * ```\n *\n * @param {string} pattern\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @ajv-errors\n */\nexport const Pattern = withErrorMsg(\"pattern\", (pattern: string | RegExp) => {\n return JsonEntityFn((store: JsonEntityStore) => {\n store.itemSchema.pattern(pattern);\n });\n});\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Required = void 0;
4
+ const withErrorMsg_1 = require("../../utils/withErrorMsg");
4
5
  const allow_1 = require("./allow");
5
6
  const optional_1 = require("./optional");
6
7
  /**
@@ -46,8 +47,7 @@ const optional_1 = require("./optional");
46
47
  * @schema
47
48
  * @input
48
49
  */
49
- function Required(required = true, ...allowedRequiredValues) {
50
+ exports.Required = (0, withErrorMsg_1.withErrorMsg)("required", (required = true, ...allowedRequiredValues) => {
50
51
  return required ? (0, allow_1.Allow)(...allowedRequiredValues) : (0, optional_1.Optional)();
51
- }
52
- exports.Required = Required;
52
+ });
53
53
  //# sourceMappingURL=required.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"required.js","sourceRoot":"","sources":["../../../../src/decorators/common/required.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAC9B,yCAAoC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,SAAgB,QAAQ,CAAC,WAAoB,IAAI,EAAE,GAAG,qBAA4B;IAChF,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,aAAK,EAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAQ,GAAE,CAAC;AACjE,CAAC;AAFD,4BAEC","sourcesContent":["import {Allow} from \"./allow\";\nimport {Optional} from \"./optional\";\n\n/**\n * Add required annotation on Property or Parameter.\n *\n * The @@Required@@ decorator can be used on two cases.\n *\n * To decorate a parameters:\n *\n * ```typescript\n * @Post(\"/\")\n * async method(@Required() @BodyParams(\"field\") field: string) {}\n * ```\n *\n * To decorate a model:\n *\n * ```typescript\n * class Model {\n * @Required()\n * field: string;\n * }\n * ```\n *\n * ::: tip\n * Required will throw a BadRequest when the given value is `null`, an empty string or `undefined`.\n * :::\n *\n * ### Allow values\n *\n * In some case, you didn't want trigger a BadRequest when the value is an empty string for example.\n * The decorator `@Allow()`, allow you to configure a value list for which there will be no exception.\n *\n * ```typescript\n * class Model {\n * @Allow(\"\") // add automatically required flag\n * field: string;\n * }\n * ```\n *\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function Required(required: boolean = true, ...allowedRequiredValues: any[]) {\n return required ? Allow(...allowedRequiredValues) : Optional();\n}\n"]}
1
+ {"version":3,"file":"required.js","sourceRoot":"","sources":["../../../../src/decorators/common/required.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AACtD,mCAA8B;AAC9B,yCAAoC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACU,QAAA,QAAQ,GAAG,IAAA,2BAAY,EAAC,UAAU,EAAE,CAAC,WAAoB,IAAI,EAAE,GAAG,qBAA4B,EAAE,EAAE;IAC7G,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAA,aAAK,EAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAQ,GAAE,CAAC;AACjE,CAAC,CAAC,CAAC","sourcesContent":["import {withErrorMsg} from \"../../utils/withErrorMsg\";\nimport {Allow} from \"./allow\";\nimport {Optional} from \"./optional\";\n\n/**\n * Add required annotation on Property or Parameter.\n *\n * The @@Required@@ decorator can be used on two cases.\n *\n * To decorate a parameters:\n *\n * ```typescript\n * @Post(\"/\")\n * async method(@Required() @BodyParams(\"field\") field: string) {}\n * ```\n *\n * To decorate a model:\n *\n * ```typescript\n * class Model {\n * @Required()\n * field: string;\n * }\n * ```\n *\n * ::: tip\n * Required will throw a BadRequest when the given value is `null`, an empty string or `undefined`.\n * :::\n *\n * ### Allow values\n *\n * In some case, you didn't want trigger a BadRequest when the value is an empty string for example.\n * The decorator `@Allow()`, allow you to configure a value list for which there will be no exception.\n *\n * ```typescript\n * class Model {\n * @Allow(\"\") // add automatically required flag\n * field: string;\n * }\n * ```\n *\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport const Required = withErrorMsg(\"required\", (required: boolean = true, ...allowedRequiredValues: any[]) => {\n return required ? Allow(...allowedRequiredValues) : Optional();\n});\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeError = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const errorMsg_1 = require("./errorMsg");
6
+ const jsonEntityFn_1 = require("./jsonEntityFn");
7
+ /**
8
+ * Create a new custom formats validator
9
+ * @param name
10
+ * @param options
11
+ * @decorator
12
+ * @ajv
13
+ */
14
+ function TypeError(msg) {
15
+ return (0, jsonEntityFn_1.JsonEntityFn)(() => (0, core_1.useDecorators)((0, errorMsg_1.ErrorMsg)({ type: msg })));
16
+ }
17
+ exports.TypeError = TypeError;
18
+ //# sourceMappingURL=typeError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeError.js","sourceRoot":"","sources":["../../../../src/decorators/common/typeError.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,yCAAoC;AACpC,iDAA4C;AAE5C;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,GAAW;IACnC,OAAO,IAAA,2BAAY,EAAC,GAAG,EAAE,CAAC,IAAA,oBAAa,EAAC,IAAA,mBAAQ,EAAC,EAAC,IAAI,EAAE,GAAG,EAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,8BAEC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {ErrorMsg} from \"./errorMsg\";\nimport {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 TypeError(msg: string): ClassDecorator {\n return JsonEntityFn(() => useDecorators(ErrorMsg({type: msg})));\n}\n"]}
package/lib/cjs/index.js CHANGED
@@ -34,9 +34,11 @@ tslib_1.__exportStar(require("./decorators/common/anyOf"), exports);
34
34
  tslib_1.__exportStar(require("./decorators/common/const"), exports);
35
35
  tslib_1.__exportStar(require("./decorators/common/customKey"), exports);
36
36
  tslib_1.__exportStar(require("./decorators/common/default"), exports);
37
+ tslib_1.__exportStar(require("./decorators/common/defaultMsg"), exports);
37
38
  tslib_1.__exportStar(require("./decorators/common/description"), exports);
38
39
  tslib_1.__exportStar(require("./decorators/common/discriminatorKey"), exports);
39
40
  tslib_1.__exportStar(require("./decorators/common/enum"), exports);
41
+ tslib_1.__exportStar(require("./decorators/common/errorMsg"), exports);
40
42
  tslib_1.__exportStar(require("./decorators/common/example"), exports);
41
43
  tslib_1.__exportStar(require("./decorators/common/examples"), exports);
42
44
  tslib_1.__exportStar(require("./decorators/common/exclusiveMaximum"), exports);
@@ -65,6 +67,7 @@ tslib_1.__exportStar(require("./decorators/common/required"), exports);
65
67
  tslib_1.__exportStar(require("./decorators/common/requiredGroups"), exports);
66
68
  tslib_1.__exportStar(require("./decorators/common/schema"), exports);
67
69
  tslib_1.__exportStar(require("./decorators/common/title"), exports);
70
+ tslib_1.__exportStar(require("./decorators/common/typeError"), exports);
68
71
  tslib_1.__exportStar(require("./decorators/common/writeOnly"), exports);
69
72
  tslib_1.__exportStar(require("./decorators/config/jsonEntityComponent"), exports);
70
73
  tslib_1.__exportStar(require("./decorators/generics/genericOf"), exports);
@@ -154,4 +157,5 @@ tslib_1.__exportStar(require("./utils/serializeEnumValues"), exports);
154
157
  tslib_1.__exportStar(require("./utils/toJsonMapCollection"), exports);
155
158
  tslib_1.__exportStar(require("./utils/toJsonRegex"), exports);
156
159
  tslib_1.__exportStar(require("./utils/transformToOS2"), exports);
160
+ tslib_1.__exportStar(require("./utils/withErrorMsg"), exports);
157
161
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iEAAuC;AACvC,mEAAyC;AACzC,sEAA4C;AAC5C,4EAAkD;AAClD,kEAAwC;AACxC,qEAA2C;AAC3C,iEAAuC;AACvC,oEAA0C;AAC1C,gEAAsC;AACtC,wEAA8C;AAC9C,oEAA0C;AAC1C,kEAAwC;AACxC,yEAA+C;AAC/C,sEAA4C;AAC5C,gFAAsD;AACtD,sFAA4D;AAC5D,gFAAsD;AACtD,4EAAkD;AAClD,iFAAuD;AACvD,4EAAkD;AAClD,iFAAuD;AACvD,+EAAqD;AACrD,mFAAyD;AACzD,oEAA0C;AAC1C,oEAA0C;AAC1C,kEAAwC;AACxC,oEAA0C;AAC1C,oEAA0C;AAC1C,wEAA8C;AAC9C,sEAA4C;AAC5C,0EAAgD;AAChD,+EAAqD;AACrD,mEAAyC;AACzC,sEAA4C;AAC5C,uEAA6C;AAC7C,+EAAqD;AACrD,+EAAqD;AACrD,qEAA2C;AAC3C,4EAAkD;AAClD,qEAA2C;AAC3C,qEAA2C;AAC3C,qEAA2C;AAC3C,sEAA4C;AAC5C,2EAAiD;AACjD,wEAA8C;AAC9C,sEAA4C;AAC5C,wEAA8C;AAC9C,sEAA4C;AAC5C,yEAA+C;AAC/C,mEAAyC;AACzC,uEAA6C;AAC7C,oEAA0C;AAC1C,uEAA6C;AAC7C,sEAA4C;AAC5C,uEAA6C;AAC7C,uEAA6C;AAC7C,uEAA6C;AAC7C,uEAA6C;AAC7C,6EAAmD;AACnD,qEAA2C;AAC3C,oEAA0C;AAC1C,wEAA8C;AAC9C,kFAAwD;AACxD,0EAAgD;AAChD,yEAA+C;AAC/C,6EAAmD;AACnD,2EAAiD;AACjD,8EAAoD;AACpD,6EAAmD;AACnD,yEAA+C;AAC/C,qEAA2C;AAC3C,yEAA+C;AAC/C,2EAAiD;AACjD,8EAAoD;AACpD,gFAAsD;AACtD,0EAAgD;AAChD,uEAA6C;AAC7C,2EAAiD;AACjD,2EAAiD;AACjD,0EAAgD;AAChD,wEAA8C;AAC9C,2EAAiD;AACjD,yEAA+C;AAC/C,0EAAgD;AAChD,uEAA6C;AAC7C,uEAA6C;AAC7C,oEAA0C;AAC1C,gEAAsC;AACtC,kEAAwC;AACxC,qEAA2C;AAC3C,mEAAyC;AACzC,mEAAyC;AACzC,+DAAqC;AACrC,2DAAiC;AACjC,mEAAyC;AACzC,iEAAuC;AACvC,yEAA+C;AAC/C,sEAA4C;AAC5C,iEAAuC;AACvC,sEAA4C;AAC5C,sEAA4C;AAC5C,qEAA2C;AAC3C,mEAAyC;AACzC,gEAAsC;AACtC,8DAAoC;AACpC,6DAAmC;AACnC,8DAAoC;AACpC,6DAAmC;AACnC,sEAA4C;AAC5C,sEAA4C;AAC5C,uEAA6C;AAC7C,oEAA0C;AAC1C,yEAA+C;AAC/C,iFAAuD;AACvD,4DAAkC;AAClC,mEAAyC;AACzC,6DAAmC;AACnC,oEAA0C;AAC1C,uDAA6B;AAC7B,+DAAqC;AACrC,2DAAiC;AACjC,kEAAwC;AACxC,qEAA2C;AAC3C,qEAA2C;AAC3C,wEAA8C;AAC9C,gEAAsC;AACtC,8DAAoC;AACpC,sEAA4C;AAC5C,sEAA4C;AAC5C,sEAA4C;AAC5C,wEAA8C;AAC9C,0DAAgC;AAChC,8DAAoC;AACpC,kEAAwC;AACxC,6DAAmC;AACnC,kEAAwC;AACxC,8DAAoC;AACpC,+DAAqC;AACrC,+DAAqC;AACrC,kEAAwC;AACxC,kEAAwC;AACxC,8DAAoC;AACpC,iEAAuC;AACvC,4DAAkC;AAClC,uEAA6C;AAC7C,sDAA4B;AAC5B,sEAA4C;AAC5C,sEAA4C;AAC5C,8DAAoC;AACpC,iEAAuC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/anyMapper\";\nexport * from \"./components/classMapper\";\nexport * from \"./components/genericsMapper\";\nexport * from \"./components/inheritedClassMapper\";\nexport * from \"./components/itemMapper\";\nexport * from \"./components/lazyRefMapper\";\nexport * from \"./components/mapMapper\";\nexport * from \"./components/objectMapper\";\nexport * from \"./components/ofMapper\";\nexport * from \"./components/propertiesMapper\";\nexport * from \"./components/schemaMapper\";\nexport * from \"./constants/httpMethods\";\nexport * from \"./constants/httpStatusMessages\";\nexport * from \"./decorators/class/children\";\nexport * from \"./decorators/class/discriminatorValue\";\nexport * from \"./decorators/collections/collectionContains\";\nexport * from \"./decorators/collections/collectionOf\";\nexport * from \"./decorators/collections/maxItems\";\nexport * from \"./decorators/collections/maxProperties\";\nexport * from \"./decorators/collections/minItems\";\nexport * from \"./decorators/collections/minProperties\";\nexport * from \"./decorators/collections/uniqueItems\";\nexport * from \"./decorators/common/additionalProperties\";\nexport * from \"./decorators/common/allOf\";\nexport * from \"./decorators/common/allow\";\nexport * from \"./decorators/common/any\";\nexport * from \"./decorators/common/anyOf\";\nexport * from \"./decorators/common/const\";\nexport * from \"./decorators/common/customKey\";\nexport * from \"./decorators/common/default\";\nexport * from \"./decorators/common/description\";\nexport * from \"./decorators/common/discriminatorKey\";\nexport * from \"./decorators/common/enum\";\nexport * from \"./decorators/common/example\";\nexport * from \"./decorators/common/examples\";\nexport * from \"./decorators/common/exclusiveMaximum\";\nexport * from \"./decorators/common/exclusiveMinimum\";\nexport * from \"./decorators/common/format\";\nexport * from \"./decorators/common/forwardGroups\";\nexport * from \"./decorators/common/groups\";\nexport * from \"./decorators/common/hidden\";\nexport * from \"./decorators/common/ignore\";\nexport * from \"./decorators/common/integer\";\nexport * from \"./decorators/common/jsonEntityFn\";\nexport * from \"./decorators/common/maxLength\";\nexport * from \"./decorators/common/maximum\";\nexport * from \"./decorators/common/minLength\";\nexport * from \"./decorators/common/minimum\";\nexport * from \"./decorators/common/multipleOf\";\nexport * from \"./decorators/common/name\";\nexport * from \"./decorators/common/nullable\";\nexport * from \"./decorators/common/oneOf\";\nexport * from \"./decorators/common/optional\";\nexport * from \"./decorators/common/pattern\";\nexport * from \"./decorators/common/property\";\nexport * from \"./decorators/common/readOnly\";\nexport * from \"./decorators/common/recordOf\";\nexport * from \"./decorators/common/required\";\nexport * from \"./decorators/common/requiredGroups\";\nexport * from \"./decorators/common/schema\";\nexport * from \"./decorators/common/title\";\nexport * from \"./decorators/common/writeOnly\";\nexport * from \"./decorators/config/jsonEntityComponent\";\nexport * from \"./decorators/generics/genericOf\";\nexport * from \"./decorators/generics/generics\";\nexport * from \"./decorators/operations/acceptMime\";\nexport * from \"./decorators/operations/consumes\";\nexport * from \"./decorators/operations/contentType\";\nexport * from \"./decorators/operations/deprecated\";\nexport * from \"./decorators/operations/header\";\nexport * from \"./decorators/operations/in\";\nexport * from \"./decorators/operations/inFile\";\nexport * from \"./decorators/operations/location\";\nexport * from \"./decorators/operations/operationId\";\nexport * from \"./decorators/operations/operationPath\";\nexport * from \"./decorators/operations/partial\";\nexport * from \"./decorators/operations/path\";\nexport * from \"./decorators/operations/produces\";\nexport * from \"./decorators/operations/redirect\";\nexport * from \"./decorators/operations/returns\";\nexport * from \"./decorators/operations/route\";\nexport * from \"./decorators/operations/security\";\nexport * from \"./decorators/operations/status\";\nexport * from \"./decorators/operations/summary\";\nexport * from \"./decorators/operations/tags\";\nexport * from \"./decorators/operations/view\";\nexport * from \"./domain/DecoratorContext\";\nexport * from \"./domain/JsonAliasMap\";\nexport * from \"./domain/JsonClassStore\";\nexport * from \"./domain/JsonDiscriminator\";\nexport * from \"./domain/JsonEntityStore\";\nexport * from \"./domain/JsonFormatTypes\";\nexport * from \"./domain/JsonLazyRef\";\nexport * from \"./domain/JsonMap\";\nexport * from \"./domain/JsonMethodStore\";\nexport * from \"./domain/JsonOperation\";\nexport * from \"./domain/JsonOperationPathsMap\";\nexport * from \"./domain/JsonOperationRoute\";\nexport * from \"./domain/JsonParameter\";\nexport * from \"./domain/JsonParameterStore\";\nexport * from \"./domain/JsonParameterTypes\";\nexport * from \"./domain/JsonPropertyStore\";\nexport * from \"./domain/JsonRequestBody\";\nexport * from \"./domain/JsonResponse\";\nexport * from \"./domain/JsonSchema\";\nexport * from \"./domain/SpecTypes\";\nexport * from \"./hooks/alterIgnore\";\nexport * from \"./hooks/alterOneOf\";\nexport * from \"./hooks/alterRequiredGroups\";\nexport * from \"./interfaces/IgnoreCallback\";\nexport * from \"./interfaces/JsonHookContext\";\nexport * from \"./interfaces/JsonOpenSpec\";\nexport * from \"./interfaces/JsonSchemaOptions\";\nexport * from \"./registries/JsonSchemaMapperContainer\";\nexport * from \"./utils/buildPath\";\nexport * from \"./utils/concatParameters\";\nexport * from \"./utils/concatPath\";\nexport * from \"./utils/defineStatusModel\";\nexport * from \"./utils/from\";\nexport * from \"./utils/generateSpec\";\nexport * from \"./utils/generics\";\nexport * from \"./utils/getComputedType\";\nexport * from \"./utils/getInheritedStores\";\nexport * from \"./utils/getJsonEntityStore\";\nexport * from \"./utils/getJsonPathParameters\";\nexport * from \"./utils/getJsonSchema\";\nexport * from \"./utils/getJsonType\";\nexport * from \"./utils/getOperationsRoutes\";\nexport * from \"./utils/getOperationsStores\";\nexport * from \"./utils/getPropertiesStores\";\nexport * from \"./utils/getRequiredProperties\";\nexport * from \"./utils/getSpec\";\nexport * from \"./utils/getSpecType\";\nexport * from \"./utils/isSuccessStatus\";\nexport * from \"./utils/mapHeaders\";\nexport * from \"./utils/mapNullableType\";\nexport * from \"./utils/mapOpenSpec\";\nexport * from \"./utils/mapOpenSpec2\";\nexport * from \"./utils/mapOpenSpec3\";\nexport * from \"./utils/mapOpenSpecInfo\";\nexport * from \"./utils/mapRouteOptions\";\nexport * from \"./utils/matchGroups\";\nexport * from \"./utils/mergeOperation\";\nexport * from \"./utils/mergeSpec\";\nexport * from \"./utils/operationIdFormatter\";\nexport * from \"./utils/ref\";\nexport * from \"./utils/serializeEnumValues\";\nexport * from \"./utils/toJsonMapCollection\";\nexport * from \"./utils/toJsonRegex\";\nexport * from \"./utils/transformToOS2\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iEAAuC;AACvC,mEAAyC;AACzC,sEAA4C;AAC5C,4EAAkD;AAClD,kEAAwC;AACxC,qEAA2C;AAC3C,iEAAuC;AACvC,oEAA0C;AAC1C,gEAAsC;AACtC,wEAA8C;AAC9C,oEAA0C;AAC1C,kEAAwC;AACxC,yEAA+C;AAC/C,sEAA4C;AAC5C,gFAAsD;AACtD,sFAA4D;AAC5D,gFAAsD;AACtD,4EAAkD;AAClD,iFAAuD;AACvD,4EAAkD;AAClD,iFAAuD;AACvD,+EAAqD;AACrD,mFAAyD;AACzD,oEAA0C;AAC1C,oEAA0C;AAC1C,kEAAwC;AACxC,oEAA0C;AAC1C,oEAA0C;AAC1C,wEAA8C;AAC9C,sEAA4C;AAC5C,yEAA+C;AAC/C,0EAAgD;AAChD,+EAAqD;AACrD,mEAAyC;AACzC,uEAA6C;AAC7C,sEAA4C;AAC5C,uEAA6C;AAC7C,+EAAqD;AACrD,+EAAqD;AACrD,qEAA2C;AAC3C,4EAAkD;AAClD,qEAA2C;AAC3C,qEAA2C;AAC3C,qEAA2C;AAC3C,sEAA4C;AAC5C,2EAAiD;AACjD,wEAA8C;AAC9C,sEAA4C;AAC5C,wEAA8C;AAC9C,sEAA4C;AAC5C,yEAA+C;AAC/C,mEAAyC;AACzC,uEAA6C;AAC7C,oEAA0C;AAC1C,uEAA6C;AAC7C,sEAA4C;AAC5C,uEAA6C;AAC7C,uEAA6C;AAC7C,uEAA6C;AAC7C,uEAA6C;AAC7C,6EAAmD;AACnD,qEAA2C;AAC3C,oEAA0C;AAC1C,wEAA8C;AAC9C,wEAA8C;AAC9C,kFAAwD;AACxD,0EAAgD;AAChD,yEAA+C;AAC/C,6EAAmD;AACnD,2EAAiD;AACjD,8EAAoD;AACpD,6EAAmD;AACnD,yEAA+C;AAC/C,qEAA2C;AAC3C,yEAA+C;AAC/C,2EAAiD;AACjD,8EAAoD;AACpD,gFAAsD;AACtD,0EAAgD;AAChD,uEAA6C;AAC7C,2EAAiD;AACjD,2EAAiD;AACjD,0EAAgD;AAChD,wEAA8C;AAC9C,2EAAiD;AACjD,yEAA+C;AAC/C,0EAAgD;AAChD,uEAA6C;AAC7C,uEAA6C;AAC7C,oEAA0C;AAC1C,gEAAsC;AACtC,kEAAwC;AACxC,qEAA2C;AAC3C,mEAAyC;AACzC,mEAAyC;AACzC,+DAAqC;AACrC,2DAAiC;AACjC,mEAAyC;AACzC,iEAAuC;AACvC,yEAA+C;AAC/C,sEAA4C;AAC5C,iEAAuC;AACvC,sEAA4C;AAC5C,sEAA4C;AAC5C,qEAA2C;AAC3C,mEAAyC;AACzC,gEAAsC;AACtC,8DAAoC;AACpC,6DAAmC;AACnC,8DAAoC;AACpC,6DAAmC;AACnC,sEAA4C;AAC5C,sEAA4C;AAC5C,uEAA6C;AAC7C,oEAA0C;AAC1C,yEAA+C;AAC/C,iFAAuD;AACvD,4DAAkC;AAClC,mEAAyC;AACzC,6DAAmC;AACnC,oEAA0C;AAC1C,uDAA6B;AAC7B,+DAAqC;AACrC,2DAAiC;AACjC,kEAAwC;AACxC,qEAA2C;AAC3C,qEAA2C;AAC3C,wEAA8C;AAC9C,gEAAsC;AACtC,8DAAoC;AACpC,sEAA4C;AAC5C,sEAA4C;AAC5C,sEAA4C;AAC5C,wEAA8C;AAC9C,0DAAgC;AAChC,8DAAoC;AACpC,kEAAwC;AACxC,6DAAmC;AACnC,kEAAwC;AACxC,8DAAoC;AACpC,+DAAqC;AACrC,+DAAqC;AACrC,kEAAwC;AACxC,kEAAwC;AACxC,8DAAoC;AACpC,iEAAuC;AACvC,4DAAkC;AAClC,uEAA6C;AAC7C,sDAA4B;AAC5B,sEAA4C;AAC5C,sEAA4C;AAC5C,8DAAoC;AACpC,iEAAuC;AACvC,+DAAqC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/anyMapper\";\nexport * from \"./components/classMapper\";\nexport * from \"./components/genericsMapper\";\nexport * from \"./components/inheritedClassMapper\";\nexport * from \"./components/itemMapper\";\nexport * from \"./components/lazyRefMapper\";\nexport * from \"./components/mapMapper\";\nexport * from \"./components/objectMapper\";\nexport * from \"./components/ofMapper\";\nexport * from \"./components/propertiesMapper\";\nexport * from \"./components/schemaMapper\";\nexport * from \"./constants/httpMethods\";\nexport * from \"./constants/httpStatusMessages\";\nexport * from \"./decorators/class/children\";\nexport * from \"./decorators/class/discriminatorValue\";\nexport * from \"./decorators/collections/collectionContains\";\nexport * from \"./decorators/collections/collectionOf\";\nexport * from \"./decorators/collections/maxItems\";\nexport * from \"./decorators/collections/maxProperties\";\nexport * from \"./decorators/collections/minItems\";\nexport * from \"./decorators/collections/minProperties\";\nexport * from \"./decorators/collections/uniqueItems\";\nexport * from \"./decorators/common/additionalProperties\";\nexport * from \"./decorators/common/allOf\";\nexport * from \"./decorators/common/allow\";\nexport * from \"./decorators/common/any\";\nexport * from \"./decorators/common/anyOf\";\nexport * from \"./decorators/common/const\";\nexport * from \"./decorators/common/customKey\";\nexport * from \"./decorators/common/default\";\nexport * from \"./decorators/common/defaultMsg\";\nexport * from \"./decorators/common/description\";\nexport * from \"./decorators/common/discriminatorKey\";\nexport * from \"./decorators/common/enum\";\nexport * from \"./decorators/common/errorMsg\";\nexport * from \"./decorators/common/example\";\nexport * from \"./decorators/common/examples\";\nexport * from \"./decorators/common/exclusiveMaximum\";\nexport * from \"./decorators/common/exclusiveMinimum\";\nexport * from \"./decorators/common/format\";\nexport * from \"./decorators/common/forwardGroups\";\nexport * from \"./decorators/common/groups\";\nexport * from \"./decorators/common/hidden\";\nexport * from \"./decorators/common/ignore\";\nexport * from \"./decorators/common/integer\";\nexport * from \"./decorators/common/jsonEntityFn\";\nexport * from \"./decorators/common/maxLength\";\nexport * from \"./decorators/common/maximum\";\nexport * from \"./decorators/common/minLength\";\nexport * from \"./decorators/common/minimum\";\nexport * from \"./decorators/common/multipleOf\";\nexport * from \"./decorators/common/name\";\nexport * from \"./decorators/common/nullable\";\nexport * from \"./decorators/common/oneOf\";\nexport * from \"./decorators/common/optional\";\nexport * from \"./decorators/common/pattern\";\nexport * from \"./decorators/common/property\";\nexport * from \"./decorators/common/readOnly\";\nexport * from \"./decorators/common/recordOf\";\nexport * from \"./decorators/common/required\";\nexport * from \"./decorators/common/requiredGroups\";\nexport * from \"./decorators/common/schema\";\nexport * from \"./decorators/common/title\";\nexport * from \"./decorators/common/typeError\";\nexport * from \"./decorators/common/writeOnly\";\nexport * from \"./decorators/config/jsonEntityComponent\";\nexport * from \"./decorators/generics/genericOf\";\nexport * from \"./decorators/generics/generics\";\nexport * from \"./decorators/operations/acceptMime\";\nexport * from \"./decorators/operations/consumes\";\nexport * from \"./decorators/operations/contentType\";\nexport * from \"./decorators/operations/deprecated\";\nexport * from \"./decorators/operations/header\";\nexport * from \"./decorators/operations/in\";\nexport * from \"./decorators/operations/inFile\";\nexport * from \"./decorators/operations/location\";\nexport * from \"./decorators/operations/operationId\";\nexport * from \"./decorators/operations/operationPath\";\nexport * from \"./decorators/operations/partial\";\nexport * from \"./decorators/operations/path\";\nexport * from \"./decorators/operations/produces\";\nexport * from \"./decorators/operations/redirect\";\nexport * from \"./decorators/operations/returns\";\nexport * from \"./decorators/operations/route\";\nexport * from \"./decorators/operations/security\";\nexport * from \"./decorators/operations/status\";\nexport * from \"./decorators/operations/summary\";\nexport * from \"./decorators/operations/tags\";\nexport * from \"./decorators/operations/view\";\nexport * from \"./domain/DecoratorContext\";\nexport * from \"./domain/JsonAliasMap\";\nexport * from \"./domain/JsonClassStore\";\nexport * from \"./domain/JsonDiscriminator\";\nexport * from \"./domain/JsonEntityStore\";\nexport * from \"./domain/JsonFormatTypes\";\nexport * from \"./domain/JsonLazyRef\";\nexport * from \"./domain/JsonMap\";\nexport * from \"./domain/JsonMethodStore\";\nexport * from \"./domain/JsonOperation\";\nexport * from \"./domain/JsonOperationPathsMap\";\nexport * from \"./domain/JsonOperationRoute\";\nexport * from \"./domain/JsonParameter\";\nexport * from \"./domain/JsonParameterStore\";\nexport * from \"./domain/JsonParameterTypes\";\nexport * from \"./domain/JsonPropertyStore\";\nexport * from \"./domain/JsonRequestBody\";\nexport * from \"./domain/JsonResponse\";\nexport * from \"./domain/JsonSchema\";\nexport * from \"./domain/SpecTypes\";\nexport * from \"./hooks/alterIgnore\";\nexport * from \"./hooks/alterOneOf\";\nexport * from \"./hooks/alterRequiredGroups\";\nexport * from \"./interfaces/IgnoreCallback\";\nexport * from \"./interfaces/JsonHookContext\";\nexport * from \"./interfaces/JsonOpenSpec\";\nexport * from \"./interfaces/JsonSchemaOptions\";\nexport * from \"./registries/JsonSchemaMapperContainer\";\nexport * from \"./utils/buildPath\";\nexport * from \"./utils/concatParameters\";\nexport * from \"./utils/concatPath\";\nexport * from \"./utils/defineStatusModel\";\nexport * from \"./utils/from\";\nexport * from \"./utils/generateSpec\";\nexport * from \"./utils/generics\";\nexport * from \"./utils/getComputedType\";\nexport * from \"./utils/getInheritedStores\";\nexport * from \"./utils/getJsonEntityStore\";\nexport * from \"./utils/getJsonPathParameters\";\nexport * from \"./utils/getJsonSchema\";\nexport * from \"./utils/getJsonType\";\nexport * from \"./utils/getOperationsRoutes\";\nexport * from \"./utils/getOperationsStores\";\nexport * from \"./utils/getPropertiesStores\";\nexport * from \"./utils/getRequiredProperties\";\nexport * from \"./utils/getSpec\";\nexport * from \"./utils/getSpecType\";\nexport * from \"./utils/isSuccessStatus\";\nexport * from \"./utils/mapHeaders\";\nexport * from \"./utils/mapNullableType\";\nexport * from \"./utils/mapOpenSpec\";\nexport * from \"./utils/mapOpenSpec2\";\nexport * from \"./utils/mapOpenSpec3\";\nexport * from \"./utils/mapOpenSpecInfo\";\nexport * from \"./utils/mapRouteOptions\";\nexport * from \"./utils/matchGroups\";\nexport * from \"./utils/mergeOperation\";\nexport * from \"./utils/mergeSpec\";\nexport * from \"./utils/operationIdFormatter\";\nexport * from \"./utils/ref\";\nexport * from \"./utils/serializeEnumValues\";\nexport * from \"./utils/toJsonMapCollection\";\nexport * from \"./utils/toJsonRegex\";\nexport * from \"./utils/transformToOS2\";\nexport * from \"./utils/withErrorMsg\";\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withErrorMsg = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const errorMsg_1 = require("../decorators/common/errorMsg");
6
+ function withErrorMsg(errorKey, originalDecorator) {
7
+ const schema = {};
8
+ return ((...decoratorOptions) => {
9
+ const decorator = (0, core_1.useDecorators)(originalDecorator(...decoratorOptions));
10
+ decorator.Error = (message) => {
11
+ schema.message = message;
12
+ return (0, core_1.useDecorators)(decorator, schema.message && (0, errorMsg_1.ErrorMsg)({ [errorKey]: message }));
13
+ };
14
+ return decorator;
15
+ });
16
+ }
17
+ exports.withErrorMsg = withErrorMsg;
18
+ //# sourceMappingURL=withErrorMsg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withErrorMsg.js","sourceRoot":"","sources":["../../../src/utils/withErrorMsg.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,4DAAuD;AAYvD,SAAgB,YAAY,CAC1B,QAAgB,EAChB,iBAA4B;IAE5B,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,OAAO,CAAC,CAAC,GAAG,gBAAuB,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,IAAA,oBAAa,EAAC,iBAAiB,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;QACvE,SAAiB,CAAC,KAAK,GAAG,CAAC,OAAe,EAAE,EAAE;YAC7C,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;YACzB,OAAO,IAAA,oBAAa,EAAC,SAAS,EAAE,MAAM,CAAC,OAAO,IAAI,IAAA,mBAAQ,EAAC,EAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;QACrF,CAAC,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC,CAAQ,CAAC;AACZ,CAAC;AAfD,oCAeC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {ErrorMsg} from \"../decorators/common/errorMsg\";\n\nexport interface ErrorChainedMethods<T> {\n <T>(target: Object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<T> | number): any;\n\n Error(msg: string): this;\n}\n\nexport type ErrorChainedDecorator<Decorator extends (...args: any[]) => any> = (\n ...args: Parameters<Decorator>\n) => ErrorChainedMethods<Decorator>;\n\nexport function withErrorMsg<Decorator extends (...args: any[]) => any>(\n errorKey: string,\n originalDecorator: Decorator\n): ErrorChainedDecorator<Decorator> {\n const schema: any = {};\n\n return ((...decoratorOptions: any[]) => {\n const decorator = useDecorators(originalDecorator(...decoratorOptions));\n (decorator as any).Error = (message: string) => {\n schema.message = message;\n return useDecorators(decorator, schema.message && ErrorMsg({[errorKey]: message}));\n };\n\n return decorator;\n }) as any;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "../common/jsonEntityFn.js";
2
3
  /**
3
4
  * The value `maxItems` MUST be a non-negative integer.
@@ -44,13 +45,14 @@ import { JsonEntityFn } from "../common/jsonEntityFn.js";
44
45
  * @schema
45
46
  * @input
46
47
  * @collections
48
+ * @ajv-errors
47
49
  */
48
- export function MaxItems(maxItems) {
50
+ export const MaxItems = withErrorMsg("maxItems", (maxItems) => {
49
51
  if (maxItems < 0) {
50
52
  throw new Error("The value of maxItems MUST be a non-negative integer.");
51
53
  }
52
54
  return JsonEntityFn((storedJson) => {
53
55
  storedJson.schema.maxItems(maxItems);
54
56
  });
55
- }
57
+ });
56
58
  //# sourceMappingURL=maxItems.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"maxItems.js","sourceRoot":"","sources":["../../../../src/decorators/collections/maxItems.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAgB;IACvC,IAAI,QAAQ,GAAG,CAAC,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KAC1E;IAED,OAAO,YAAY,CAAC,CAAC,UAAU,EAAE,EAAE;QACjC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {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 */\nexport function 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
+ {"version":3,"file":"maxItems.js","sourceRoot":"","sources":["../../../../src/decorators/collections/maxItems.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC,UAAU,EAAE,CAAC,QAAgB,EAAE,EAAE;IACpE,IAAI,QAAQ,GAAG,CAAC,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KAC1E;IAED,OAAO,YAAY,CAAC,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,3 +1,4 @@
1
+ import { withErrorMsg } from "../../utils/withErrorMsg.js";
1
2
  import { JsonEntityFn } from "../common/jsonEntityFn.js";
2
3
  /**
3
4
  * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.
@@ -67,13 +68,14 @@ import { JsonEntityFn } from "../common/jsonEntityFn.js";
67
68
  * @schema
68
69
  * @input
69
70
  * @collections
71
+ * @ajv-errors
70
72
  */
71
- export function MaxProperties(maxProperties) {
73
+ export const MaxProperties = withErrorMsg("maxProperties", (maxProperties) => {
72
74
  if (maxProperties < 0) {
73
75
  throw new Error("The value of maxProperties MUST be a non-negative integer.");
74
76
  }
75
77
  return JsonEntityFn((store) => {
76
78
  store.isCollection ? store.schema.maxProperties(maxProperties) : store.itemSchema.maxProperties(maxProperties);
77
79
  });
78
- }
80
+ });
79
81
  //# sourceMappingURL=maxProperties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"maxProperties.js","sourceRoot":"","sources":["../../../../src/decorators/collections/maxProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,UAAU,aAAa,CAAC,aAAqB;IACjD,IAAI,aAAa,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;KAC/E;IAED,OAAO,YAAY,CAAC,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","sourcesContent":["import {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 */\nexport function 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
+ {"version":3,"file":"maxProperties.js","sourceRoot":"","sources":["../../../../src/decorators/collections/maxProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC,eAAe,EAAE,CAAC,aAAqB,EAAE,EAAE;IACnF,IAAI,aAAa,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;KAC/E;IAED,OAAO,YAAY,CAAC,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"]}