@decaf-ts/decorator-validation 1.5.8 → 1.5.10

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 (212) hide show
  1. package/LICENSE.md +0 -0
  2. package/README.md +0 -0
  3. package/dist/decorator-validation.js +1 -1
  4. package/dist/decorator-validation.js.LICENSE.txt +0 -0
  5. package/dist/esm/decorator-validation.js +1 -1
  6. package/dist/esm/decorator-validation.js.LICENSE.txt +0 -0
  7. package/{lib/esm → dist/types}/index.d.ts +1 -1
  8. package/{lib/esm → dist/types}/model/Model.d.ts +1 -0
  9. package/{lib/esm → dist/types}/model/ModelErrorDefinition.d.ts +0 -0
  10. package/{lib/esm → dist/types}/model/constants.d.ts +0 -0
  11. package/{lib/esm → dist/types}/model/construction.d.ts +0 -0
  12. package/{lib/esm → dist/types}/model/decorators.d.ts +0 -0
  13. package/{lib/esm → dist/types}/model/index.d.ts +0 -1
  14. package/{lib/esm → dist/types}/model/types.d.ts +0 -0
  15. package/{lib/esm → dist/types}/model/validation.d.ts +0 -0
  16. package/{lib/esm → dist/types}/utils/constants.d.ts +0 -0
  17. package/{lib/esm → dist/types}/utils/dates.d.ts +0 -0
  18. package/{lib/esm → dist/types}/utils/decorators.d.ts +0 -0
  19. package/{lib → dist/types}/utils/hashing.d.ts +0 -14
  20. package/{lib → dist/types}/utils/index.d.ts +1 -0
  21. package/{lib/esm → dist/types}/utils/registry.d.ts +0 -0
  22. package/{lib → dist/types}/utils/serialization.d.ts +4 -30
  23. package/{lib/esm → dist/types}/utils/strings.d.ts +0 -0
  24. package/dist/types/utils/types.d.ts +29 -0
  25. package/{lib → dist/types}/validation/Validation.d.ts +1 -1
  26. package/{lib → dist/types}/validation/Validators/DateValidator.d.ts +1 -1
  27. package/{lib → dist/types}/validation/Validators/EmailValidator.d.ts +1 -1
  28. package/{lib → dist/types}/validation/Validators/ListValidator.d.ts +1 -1
  29. package/{lib → dist/types}/validation/Validators/MaxLengthValidator.d.ts +1 -1
  30. package/{lib/esm → dist/types}/validation/Validators/MaxValidator.d.ts +1 -1
  31. package/{lib/esm → dist/types}/validation/Validators/MinLengthValidator.d.ts +1 -1
  32. package/{lib/esm → dist/types}/validation/Validators/MinValidator.d.ts +1 -1
  33. package/{lib/esm → dist/types}/validation/Validators/PasswordValidator.d.ts +1 -1
  34. package/{lib → dist/types}/validation/Validators/PatternValidator.d.ts +1 -1
  35. package/{lib/esm → dist/types}/validation/Validators/RequiredValidator.d.ts +1 -1
  36. package/{lib/esm → dist/types}/validation/Validators/StepValidator.d.ts +1 -1
  37. package/{lib → dist/types}/validation/Validators/TypeValidator.d.ts +1 -1
  38. package/{lib/esm → dist/types}/validation/Validators/URLValidator.d.ts +1 -1
  39. package/{lib/esm → dist/types}/validation/Validators/Validator.d.ts +1 -1
  40. package/{lib/esm → dist/types}/validation/Validators/ValidatorRegistry.d.ts +2 -2
  41. package/{lib/esm → dist/types}/validation/Validators/constants.d.ts +0 -0
  42. package/{lib/esm → dist/types}/validation/Validators/decorators.d.ts +0 -0
  43. package/dist/types/validation/Validators/index.d.ts +17 -0
  44. package/{lib/esm → dist/types}/validation/decorators.d.ts +0 -0
  45. package/{lib/esm → dist/types}/validation/index.d.ts +0 -0
  46. package/{lib/validation/Validators → dist/types/validation}/types.d.ts +49 -3
  47. package/lib/esm/index.js +3 -1
  48. package/lib/esm/model/Model.js +8 -1
  49. package/lib/esm/model/ModelErrorDefinition.js +2 -0
  50. package/lib/esm/model/constants.js +2 -0
  51. package/lib/esm/model/construction.js +2 -0
  52. package/lib/esm/model/decorators.js +2 -0
  53. package/lib/esm/model/index.js +2 -1
  54. package/lib/esm/model/types.js +2 -0
  55. package/lib/esm/model/validation.js +2 -0
  56. package/lib/esm/utils/constants.js +2 -0
  57. package/lib/esm/utils/dates.js +2 -0
  58. package/lib/esm/utils/decorators.js +2 -0
  59. package/lib/esm/utils/hashing.js +2 -17
  60. package/lib/esm/utils/index.js +3 -0
  61. package/lib/esm/utils/registry.js +2 -0
  62. package/lib/esm/utils/serialization.js +4 -1
  63. package/lib/esm/utils/strings.js +2 -0
  64. package/lib/esm/utils/types.js +3 -0
  65. package/lib/esm/validation/Validation.js +2 -0
  66. package/lib/esm/validation/Validators/DateValidator.js +2 -0
  67. package/lib/esm/validation/Validators/EmailValidator.js +2 -0
  68. package/lib/esm/validation/Validators/ListValidator.js +2 -0
  69. package/lib/esm/validation/Validators/MaxLengthValidator.js +2 -0
  70. package/lib/esm/validation/Validators/MaxValidator.js +2 -0
  71. package/lib/esm/validation/Validators/MinLengthValidator.js +2 -0
  72. package/lib/esm/validation/Validators/MinValidator.js +2 -0
  73. package/lib/esm/validation/Validators/PasswordValidator.js +2 -0
  74. package/lib/esm/validation/Validators/PatternValidator.js +2 -0
  75. package/lib/esm/validation/Validators/RequiredValidator.js +2 -0
  76. package/lib/esm/validation/Validators/StepValidator.js +2 -0
  77. package/lib/esm/validation/Validators/TypeValidator.js +2 -0
  78. package/lib/esm/validation/Validators/URLValidator.js +2 -0
  79. package/lib/esm/validation/Validators/Validator.js +2 -0
  80. package/lib/esm/validation/Validators/ValidatorRegistry.js +2 -0
  81. package/lib/esm/validation/Validators/constants.js +2 -0
  82. package/lib/esm/validation/Validators/decorators.js +2 -0
  83. package/lib/esm/validation/Validators/index.js +2 -35
  84. package/lib/esm/validation/decorators.js +2 -0
  85. package/lib/esm/validation/index.js +2 -0
  86. package/lib/esm/validation/types.js +2 -0
  87. package/lib/index.cjs +61 -0
  88. package/lib/model/Model.cjs +397 -0
  89. package/lib/model/ModelErrorDefinition.cjs +58 -0
  90. package/lib/model/constants.cjs +74 -0
  91. package/lib/model/construction.cjs +70 -0
  92. package/lib/model/decorators.cjs +69 -0
  93. package/lib/model/index.cjs +25 -0
  94. package/lib/model/types.cjs +4 -0
  95. package/lib/model/validation.cjs +140 -0
  96. package/lib/utils/constants.cjs +32 -0
  97. package/lib/utils/dates.cjs +253 -0
  98. package/lib/utils/decorators.cjs +24 -0
  99. package/lib/utils/hashing.cjs +90 -0
  100. package/lib/utils/index.cjs +26 -0
  101. package/lib/utils/registry.cjs +4 -0
  102. package/lib/utils/serialization.cjs +96 -0
  103. package/lib/utils/strings.cjs +37 -0
  104. package/lib/utils/types.cjs +4 -0
  105. package/lib/validation/Validation.cjs +77 -0
  106. package/lib/validation/Validators/DateValidator.cjs +59 -0
  107. package/lib/validation/Validators/EmailValidator.cjs +55 -0
  108. package/lib/validation/Validators/ListValidator.cjs +72 -0
  109. package/lib/validation/Validators/MaxLengthValidator.cjs +57 -0
  110. package/lib/validation/Validators/MaxValidator.cjs +62 -0
  111. package/lib/validation/Validators/MinLengthValidator.cjs +57 -0
  112. package/lib/validation/Validators/MinValidator.cjs +62 -0
  113. package/lib/validation/Validators/PasswordValidator.cjs +55 -0
  114. package/lib/validation/Validators/PatternValidator.cjs +75 -0
  115. package/lib/validation/Validators/RequiredValidator.cjs +62 -0
  116. package/lib/validation/Validators/StepValidator.cjs +57 -0
  117. package/lib/validation/Validators/TypeValidator.cjs +65 -0
  118. package/lib/validation/Validators/URLValidator.cjs +54 -0
  119. package/lib/validation/Validators/Validator.cjs +53 -0
  120. package/lib/validation/Validators/ValidatorRegistry.cjs +87 -0
  121. package/lib/validation/Validators/constants.cjs +139 -0
  122. package/lib/validation/Validators/decorators.cjs +30 -0
  123. package/lib/validation/Validators/index.cjs +35 -0
  124. package/lib/validation/decorators.cjs +306 -0
  125. package/lib/validation/{index.js → index.cjs} +6 -4
  126. package/lib/validation/types.cjs +4 -0
  127. package/package.json +2 -2
  128. package/lib/esm/model/utils.d.ts +0 -2
  129. package/lib/esm/model/utils.js +0 -8
  130. package/lib/esm/utils/hashing.d.ts +0 -52
  131. package/lib/esm/utils/index.d.ts +0 -7
  132. package/lib/esm/utils/serialization.d.ts +0 -79
  133. package/lib/esm/validation/Validation.d.ts +0 -51
  134. package/lib/esm/validation/Validators/DateValidator.d.ts +0 -28
  135. package/lib/esm/validation/Validators/EmailValidator.d.ts +0 -28
  136. package/lib/esm/validation/Validators/ListValidator.d.ts +0 -28
  137. package/lib/esm/validation/Validators/MaxLengthValidator.d.ts +0 -29
  138. package/lib/esm/validation/Validators/PatternValidator.d.ts +0 -37
  139. package/lib/esm/validation/Validators/TypeValidator.d.ts +0 -25
  140. package/lib/esm/validation/Validators/index.d.ts +0 -52
  141. package/lib/esm/validation/Validators/types.js +0 -1
  142. package/lib/esm/validation/types.d.ts +0 -46
  143. package/lib/index.d.ts +0 -42
  144. package/lib/index.js +0 -59
  145. package/lib/model/Model.d.ts +0 -203
  146. package/lib/model/Model.js +0 -389
  147. package/lib/model/ModelErrorDefinition.d.ts +0 -22
  148. package/lib/model/ModelErrorDefinition.js +0 -56
  149. package/lib/model/constants.d.ts +0 -56
  150. package/lib/model/constants.js +0 -72
  151. package/lib/model/construction.d.ts +0 -29
  152. package/lib/model/construction.js +0 -68
  153. package/lib/model/decorators.d.ts +0 -25
  154. package/lib/model/decorators.js +0 -67
  155. package/lib/model/index.d.ts +0 -8
  156. package/lib/model/index.js +0 -24
  157. package/lib/model/types.d.ts +0 -79
  158. package/lib/model/types.js +0 -2
  159. package/lib/model/utils.d.ts +0 -2
  160. package/lib/model/utils.js +0 -11
  161. package/lib/model/validation.d.ts +0 -14
  162. package/lib/model/validation.js +0 -138
  163. package/lib/utils/constants.d.ts +0 -26
  164. package/lib/utils/constants.js +0 -30
  165. package/lib/utils/dates.d.ts +0 -76
  166. package/lib/utils/dates.js +0 -251
  167. package/lib/utils/decorators.d.ts +0 -2
  168. package/lib/utils/decorators.js +0 -22
  169. package/lib/utils/hashing.js +0 -106
  170. package/lib/utils/index.js +0 -23
  171. package/lib/utils/registry.d.ts +0 -68
  172. package/lib/utils/registry.js +0 -2
  173. package/lib/utils/serialization.js +0 -93
  174. package/lib/utils/strings.d.ts +0 -25
  175. package/lib/utils/strings.js +0 -35
  176. package/lib/validation/Validation.js +0 -75
  177. package/lib/validation/Validators/DateValidator.js +0 -57
  178. package/lib/validation/Validators/EmailValidator.js +0 -53
  179. package/lib/validation/Validators/ListValidator.js +0 -70
  180. package/lib/validation/Validators/MaxLengthValidator.js +0 -55
  181. package/lib/validation/Validators/MaxValidator.d.ts +0 -28
  182. package/lib/validation/Validators/MaxValidator.js +0 -60
  183. package/lib/validation/Validators/MinLengthValidator.d.ts +0 -29
  184. package/lib/validation/Validators/MinLengthValidator.js +0 -55
  185. package/lib/validation/Validators/MinValidator.d.ts +0 -28
  186. package/lib/validation/Validators/MinValidator.js +0 -60
  187. package/lib/validation/Validators/PasswordValidator.d.ts +0 -28
  188. package/lib/validation/Validators/PasswordValidator.js +0 -53
  189. package/lib/validation/Validators/PatternValidator.js +0 -73
  190. package/lib/validation/Validators/RequiredValidator.d.ts +0 -28
  191. package/lib/validation/Validators/RequiredValidator.js +0 -60
  192. package/lib/validation/Validators/StepValidator.d.ts +0 -29
  193. package/lib/validation/Validators/StepValidator.js +0 -55
  194. package/lib/validation/Validators/TypeValidator.js +0 -63
  195. package/lib/validation/Validators/URLValidator.d.ts +0 -27
  196. package/lib/validation/Validators/URLValidator.js +0 -52
  197. package/lib/validation/Validators/Validator.d.ts +0 -41
  198. package/lib/validation/Validators/Validator.js +0 -51
  199. package/lib/validation/Validators/ValidatorRegistry.d.ts +0 -47
  200. package/lib/validation/Validators/ValidatorRegistry.js +0 -85
  201. package/lib/validation/Validators/constants.d.ts +0 -96
  202. package/lib/validation/Validators/constants.js +0 -137
  203. package/lib/validation/Validators/decorators.d.ts +0 -12
  204. package/lib/validation/Validators/decorators.js +0 -28
  205. package/lib/validation/Validators/index.d.ts +0 -52
  206. package/lib/validation/Validators/index.js +0 -69
  207. package/lib/validation/Validators/types.js +0 -2
  208. package/lib/validation/decorators.d.ts +0 -178
  209. package/lib/validation/decorators.js +0 -304
  210. package/lib/validation/index.d.ts +0 -4
  211. package/lib/validation/types.d.ts +0 -46
  212. package/lib/validation/types.js +0 -2
@@ -1,304 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.required = required;
4
- exports.min = min;
5
- exports.max = max;
6
- exports.step = step;
7
- exports.minlength = minlength;
8
- exports.maxlength = maxlength;
9
- exports.pattern = pattern;
10
- exports.email = email;
11
- exports.url = url;
12
- exports.type = type;
13
- exports.date = date;
14
- exports.password = password;
15
- exports.list = list;
16
- exports.set = set;
17
- require("reflect-metadata");
18
- const constants_1 = require("./Validators/constants");
19
- const strings_1 = require("../utils/strings");
20
- const dates_1 = require("../utils/dates");
21
- const decorators_1 = require("../utils/decorators");
22
- const Validation_1 = require("./Validation");
23
- /**
24
- * @summary Marks the property as required.
25
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#REQUIRED}
26
- *
27
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#REQUIRED}
28
- *
29
- * @function required
30
- *
31
- * @category Decorators
32
- */
33
- function required(message = constants_1.DEFAULT_ERROR_MESSAGES.REQUIRED) {
34
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.REQUIRED), {
35
- message: message,
36
- });
37
- }
38
- /**
39
- * @summary Defines a minimum value for the property
40
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#MIN}
41
- *
42
- * @param {number | Date} value
43
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#MIN}
44
- *
45
- * @function min
46
- * @memberOf module:decorator-validation.Decorators.Validation
47
- * @category Decorators
48
- */
49
- function min(value, message = constants_1.DEFAULT_ERROR_MESSAGES.MIN) {
50
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.MIN), {
51
- min: value,
52
- message: message,
53
- types: [Number.name, Date.name],
54
- });
55
- }
56
- /**
57
- * @summary Defines a maximum value for the property
58
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#MAX}
59
- *
60
- * @param {number | Date} value
61
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#MAX}
62
- *
63
- * @function max
64
- * @memberOf module:decorator-validation.Decorators.Validation
65
- * @category Decorators
66
- */
67
- function max(value, message = constants_1.DEFAULT_ERROR_MESSAGES.MAX) {
68
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.MAX), {
69
- max: value,
70
- message: message,
71
- types: [Number.name, Date.name],
72
- });
73
- }
74
- /**
75
- * @summary Defines a step value for the property
76
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#STEP}
77
- *
78
- * @param {number} value
79
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#STEP}
80
- *
81
- * @function step
82
- * @memberOf module:decorator-validation.Decorators.Validation
83
- * @category Decorators
84
- */
85
- function step(value, message = constants_1.DEFAULT_ERROR_MESSAGES.STEP) {
86
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.STEP), {
87
- step: value,
88
- message: message,
89
- types: [Number.name],
90
- });
91
- }
92
- /**
93
- * @summary Defines a minimum length for the property
94
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#MIN_LENGTH}
95
- *
96
- * @param {string} value
97
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#MIN_LENGTH}
98
- *
99
- * @function minlength
100
- * @memberOf module:decorator-validation.Decorators.Validation
101
- * @category Decorators
102
- */
103
- function minlength(value, message = constants_1.DEFAULT_ERROR_MESSAGES.MIN_LENGTH) {
104
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.MIN_LENGTH), {
105
- minLength: value,
106
- message: message,
107
- types: [String.name, Array.name, Set.name],
108
- });
109
- }
110
- /**
111
- * @summary Defines a maximum length for the property
112
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#MAX_LENGTH}
113
- *
114
- * @param {string} value
115
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#MAX_LENGTH}
116
- *
117
- * @function maxlength
118
- * @memberOf module:decorator-validation.Decorators.Validation
119
- * @category Decorators
120
- */
121
- function maxlength(value, message = constants_1.DEFAULT_ERROR_MESSAGES.MAX_LENGTH) {
122
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.MAX_LENGTH), {
123
- maxLength: value,
124
- message: message,
125
- types: [String.name, Array.name, Set.name],
126
- });
127
- }
128
- /**
129
- * @summary Defines a RegExp pattern the property must respect
130
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#PATTERN}
131
- *
132
- * @param {string} value
133
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#PATTERN}
134
- *
135
- * @function pattern
136
- * @memberOf module:decorator-validation.Decorators.Validation
137
- * @category Decorators
138
- */
139
- function pattern(value, message = constants_1.DEFAULT_ERROR_MESSAGES.PATTERN) {
140
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.PATTERN), {
141
- pattern: typeof value === "string" ? value : value.toString(),
142
- message: message,
143
- types: [String.name],
144
- });
145
- }
146
- /**
147
- * @summary Defines the property as an email
148
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#EMAIL}
149
- *
150
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#EMAIL}
151
- *
152
- * @function email
153
- * @memberOf module:decorator-validation.Decorators.Validation
154
- * @category Decorators
155
- */
156
- function email(message = constants_1.DEFAULT_ERROR_MESSAGES.EMAIL) {
157
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.EMAIL), {
158
- pattern: constants_1.DEFAULT_PATTERNS.EMAIL,
159
- message: message,
160
- types: [String.name],
161
- });
162
- }
163
- /**
164
- * @summary Defines the property as an URL
165
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#URL}
166
- *
167
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#URL}
168
- *
169
- * @function url
170
- * @memberOf module:decorator-validation.Decorators.Validation
171
- * @category Decorators
172
- */
173
- function url(message = constants_1.DEFAULT_ERROR_MESSAGES.URL) {
174
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.URL), {
175
- pattern: constants_1.DEFAULT_PATTERNS.URL,
176
- message: message,
177
- types: [String.name],
178
- });
179
- }
180
- /**
181
- * @summary Enforces type verification
182
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#TYPE}
183
- *
184
- * @param {string[] | string} types accepted types
185
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#TYPE}
186
- *
187
- * @function type
188
- * @memberOf module:decorator-validation.Decorators.Validation
189
- * @category Decorators
190
- */
191
- function type(types, message = constants_1.DEFAULT_ERROR_MESSAGES.TYPE) {
192
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.TYPE), {
193
- customTypes: types,
194
- message: message,
195
- });
196
- }
197
- /**
198
- * @summary Date Handler Decorator
199
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#DATE}
200
- *
201
- * Will enforce serialization according to the selected format
202
- *
203
- * @param {string} format accepted format according to {@link formatDate}
204
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#DATE}
205
- * @param {Constructor<Validator>} [validator] the Validator to be used. Defaults to {@link DateValidator}
206
- *
207
- * @function date
208
- *
209
- * @memberOf module:decorator-validation.Decorators.Validation
210
- * @category Decorators
211
- */
212
- function date(format = "dd/MM/yyyy", message = constants_1.DEFAULT_ERROR_MESSAGES.DATE) {
213
- return (target, propertyKey) => {
214
- (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.DATE), {
215
- format: format,
216
- message: message,
217
- types: [Date.name],
218
- })(target, propertyKey);
219
- const values = new WeakMap();
220
- Object.defineProperty(target, propertyKey, {
221
- configurable: false,
222
- set(newValue) {
223
- const descriptor = Object.getOwnPropertyDescriptor(this, propertyKey);
224
- if (!descriptor || descriptor.configurable)
225
- Object.defineProperty(this, propertyKey, {
226
- enumerable: true,
227
- configurable: false,
228
- get: () => values.get(this),
229
- set: (newValue) => {
230
- let val;
231
- try {
232
- val = (0, dates_1.parseDate)(format, newValue);
233
- values.set(this, val);
234
- }
235
- catch (e) {
236
- console.error((0, strings_1.sf)("Failed to parse date: {0}", e.message || e));
237
- }
238
- },
239
- });
240
- this[propertyKey] = newValue;
241
- },
242
- get() {
243
- console.log("here");
244
- },
245
- });
246
- };
247
- }
248
- /**
249
- * @summary Password Handler Decorator
250
- * @description Validators to validate a decorated property must use key {@link ValidationKeys#PASSWORD}
251
- *
252
- * @param {RegExp} [pattern] defaults to {@link PasswordPatterns#CHAR8_ONE_OF_EACH}
253
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#PASSWORD}
254
- * @param {Constructor<Validator>} [validator] Defaults to {@link PasswordValidator}
255
- *
256
- * @function password
257
- *
258
- * @memberOf module:decorator-validation.Decorators.Validation
259
- * @category Decorators
260
- */
261
- function password(pattern = constants_1.DEFAULT_PATTERNS.PASSWORD.CHAR8_ONE_OF_EACH, message = constants_1.DEFAULT_ERROR_MESSAGES.PASSWORD) {
262
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.PASSWORD), {
263
- pattern: pattern,
264
- message: message,
265
- types: [String.name],
266
- });
267
- }
268
- /**
269
- * @summary List Decorator
270
- * @description Also sets the {@link type} to the provided collection
271
- *
272
- * @param {ModelConstructor} clazz
273
- * @param {string} [collection] The collection being used. defaults to Array
274
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#LIST}
275
- * @param {Constructor<Validator>} [validator] defaults to {@link ListValidator}
276
- *
277
- * @function list
278
- *
279
- * @memberOf module:decorator-validation.Decorators.Validation
280
- * @category Decorators
281
- */
282
- function list(clazz, collection = "Array", message = constants_1.DEFAULT_ERROR_MESSAGES.LIST) {
283
- return (0, decorators_1.propMetadata)(Validation_1.Validation.key(constants_1.ValidationKeys.LIST), {
284
- clazz: Array.isArray(clazz) ? clazz.map((c) => c.name) : [clazz.name],
285
- type: collection,
286
- message: message,
287
- });
288
- }
289
- /**
290
- * @summary Set Decorator
291
- * @description Wrapper for {@link list} with the 'Set' Collection
292
- *
293
- * @param {ModelConstructor} clazz
294
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#LIST}
295
- * @param {Constructor<Validator>} [validator]
296
- *
297
- * @function set
298
- *
299
- * @memberOf module:decorator-validation.Decorators.Validation
300
- * @category Decorators
301
- */
302
- function set(clazz, message = constants_1.DEFAULT_ERROR_MESSAGES.LIST) {
303
- return list(clazz, "Set", message);
304
- }
@@ -1,4 +0,0 @@
1
- export * from "./Validators";
2
- export * from "./decorators";
3
- export * from "./types";
4
- export * from "./Validation";
@@ -1,46 +0,0 @@
1
- import { DecoratorMetadata } from "@decaf-ts/reflection";
2
- /**
3
- * @summary Type for validation decorator metadata
4
- * @memberOf module:decorator-validation.Reflection
5
- * @category Reflection
6
- */
7
- export type ValidationMetadata = {
8
- [indexer: string]: any;
9
- args?: any[];
10
- message: string;
11
- types?: string[];
12
- };
13
- /**
14
- * @summary Type for a validator property decorator definition
15
- * @memberOf module:decorator-validation.Validation
16
- * @category Validation
17
- */
18
- export type ValidationPropertyDecoratorDefinition = {
19
- prop: string | symbol;
20
- decorators: ValidationDecoratorDefinition[];
21
- };
22
- /**
23
- * @summary Type for a validator decorator definition
24
- * @memberOf module:decorator-validation.Validation
25
- * @category Validation
26
- */
27
- export type ValidationDecoratorDefinition = DecoratorMetadata & {
28
- props: ValidationElementDefinition;
29
- };
30
- /**
31
- * @summary Type for a validator element metadata
32
- * @memberOf module:decorator-validation.Validation
33
- * @category Validation
34
- */
35
- export type ValidationElementDefinition = {
36
- [indexer: string]: any;
37
- value?: string | number;
38
- message: string;
39
- types?: string[];
40
- };
41
- /**
42
- * @summary Type for a model errors
43
- * @memberOf module:decorator-validation.Validation
44
- * @category Validation
45
- */
46
- export type ModelErrors = Record<string, Record<string, string | undefined>>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });