@nest-omni/core 2.0.1-0 → 2.0.1-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/package.json +1 -1
  2. package/.history/src/common/boilerplate.polyfill_20250521135408.ts +0 -202
  3. package/.history/src/common/boilerplate.polyfill_20250712165919.ts +0 -254
  4. package/.history/src/common/boilerplate.polyfill_20250712165924.ts +0 -254
  5. package/.history/src/common/boilerplate.polyfill_20250712165927.ts +0 -254
  6. package/.history/src/common/boilerplate.polyfill_20250712170044.ts +0 -265
  7. package/.history/src/common/boilerplate.polyfill_20250712170049.ts +0 -265
  8. package/.history/src/common/boilerplate.polyfill_20250712170053.ts +0 -265
  9. package/.history/src/common/boilerplate.polyfill_20250712170610.ts +0 -280
  10. package/.history/src/common/boilerplate.polyfill_20250712170614.ts +0 -280
  11. package/.history/src/common/boilerplate.polyfill_20250712170739.ts +0 -265
  12. package/.history/src/common/boilerplate.polyfill_20250712170801.ts +0 -291
  13. package/.history/src/common/boilerplate.polyfill_20250712170809.ts +0 -317
  14. package/.history/src/common/boilerplate.polyfill_20250712170816.ts +0 -319
  15. package/.history/src/common/boilerplate.polyfill_20250712170820.ts +0 -318
  16. package/.history/src/common/boilerplate.polyfill_20250712170824.ts +0 -318
  17. package/.history/src/common/boilerplate.polyfill_20250712171040.ts +0 -289
  18. package/README.md +0 -16
  19. package/build.sh +0 -45
  20. package/dist/package.json +0 -71
  21. package/dist/yarn.lock +0 -644
  22. package/src/.hygen.js +0 -116
  23. package/src/common/abstract-client.service.ts +0 -56
  24. package/src/common/abstract.entity.ts +0 -82
  25. package/src/common/boilerplate.polyfill.ts +0 -202
  26. package/src/common/dto/abstract.dto.ts +0 -61
  27. package/src/common/dto/bulk-id.dto.ts +0 -13
  28. package/src/common/dto/create-translation.dto.ts +0 -10
  29. package/src/common/dto/index.ts +0 -6
  30. package/src/common/dto/page-meta.dto.ts +0 -37
  31. package/src/common/dto/page-options.dto.ts +0 -35
  32. package/src/common/dto/page.dto.ts +0 -36
  33. package/src/common/index.ts +0 -7
  34. package/src/common/snake-naming.strategy.ts +0 -64
  35. package/src/common/types.ts +0 -44
  36. package/src/common/utils.ts +0 -45
  37. package/src/constants/index.ts +0 -2
  38. package/src/constants/language-code.ts +0 -7
  39. package/src/constants/order.ts +0 -4
  40. package/src/decorators/api-page-ok-response.decorator.ts +0 -32
  41. package/src/decorators/auth-user.decorator.ts +0 -16
  42. package/src/decorators/controller.decorator.ts +0 -8
  43. package/src/decorators/field.decorators.ts +0 -856
  44. package/src/decorators/http.decorators.ts +0 -10
  45. package/src/decorators/index.ts +0 -12
  46. package/src/decorators/operation.decorator.ts +0 -4
  47. package/src/decorators/property.decorators.ts +0 -62
  48. package/src/decorators/public-route.decorator.ts +0 -8
  49. package/src/decorators/swagger.schema.ts +0 -117
  50. package/src/decorators/timestamp-column.decorator.ts +0 -29
  51. package/src/decorators/transform.decorators.ts +0 -159
  52. package/src/decorators/translate.decorator.ts +0 -19
  53. package/src/decorators/use-dto.decorator.ts +0 -11
  54. package/src/decorators/user-check.decorator.ts +0 -30
  55. package/src/decorators/user.decorator.ts +0 -59
  56. package/src/decorators/user_auth.decorator.ts +0 -15
  57. package/src/decorators/validator.decorators.ts +0 -98
  58. package/src/exceptions/file-not-image.exception.ts +0 -7
  59. package/src/exceptions/index.ts +0 -2
  60. package/src/exceptions/page-type.exception.ts +0 -7
  61. package/src/exceptions/user-not-found.exception.ts +0 -7
  62. package/src/filters/bad-request.filter.ts +0 -77
  63. package/src/filters/constraint-errors.ts +0 -5
  64. package/src/filters/index.ts +0 -3
  65. package/src/filters/query-failed.filter.ts +0 -32
  66. package/src/health-checker/health-checker.controller.ts +0 -51
  67. package/src/health-checker/health-checker.module.ts +0 -13
  68. package/src/health-checker/health-indicators/service.indicator.ts +0 -44
  69. package/src/helpers/common.helper.ts +0 -49
  70. package/src/helpers/date.helper.ts +0 -64
  71. package/src/helpers/index.ts +0 -2
  72. package/src/i18n/en_US/validation.json +0 -41
  73. package/src/i18n/zh_CN/validation.json +0 -41
  74. package/src/index.ts +0 -11
  75. package/src/interceptors/index.ts +0 -2
  76. package/src/interceptors/language-interceptor.service.ts +0 -28
  77. package/src/interceptors/translation-interceptor.service.ts +0 -43
  78. package/src/interfaces/IApiFile.ts +0 -4
  79. package/src/interfaces/IFile.ts +0 -8
  80. package/src/interfaces/ITranslationDecoratorInterface.ts +0 -3
  81. package/src/interfaces/index.ts +0 -3
  82. package/src/interfaces/response.ts +0 -37
  83. package/src/middlewares/index.ts +0 -4
  84. package/src/middlewares/omni-auth.middleware.ts +0 -10
  85. package/src/middlewares/powerby.middleware.ts +0 -6
  86. package/src/middlewares/request-id.middleware.ts +0 -28
  87. package/src/middlewares/xml.middleware.ts +0 -14
  88. package/src/providers/context.provider.ts +0 -109
  89. package/src/providers/generator.provider.ts +0 -66
  90. package/src/providers/index.ts +0 -2
  91. package/src/setup/bootstrap.setup.ts +0 -254
  92. package/src/setup/index.ts +0 -1
  93. package/src/shared/index.ts +0 -2
  94. package/src/shared/serviceRegistryModule.ts +0 -135
  95. package/src/shared/services/api-config.service.ts +0 -336
  96. package/src/shared/services/generator.service.ts +0 -13
  97. package/src/shared/services/index.ts +0 -4
  98. package/src/shared/services/translation.service.ts +0 -59
  99. package/src/shared/services/validator.service.ts +0 -10
  100. package/src/validator-json/decorators.ts +0 -63
  101. package/src/validator-json/default.ts +0 -257
  102. package/src/validator-json/defaultConverters.ts +0 -402
  103. package/src/validator-json/index.ts +0 -4
  104. package/src/validator-json/options.ts +0 -50
  105. package/src/validators/file-mimetype.validator.ts +0 -34
  106. package/src/validators/index.ts +0 -6
  107. package/src/validators/is-exists.validator.ts +0 -60
  108. package/src/validators/is-unique.validator.ts +0 -93
  109. package/src/validators/phone-country-code.validator.ts +0 -36
  110. package/src/validators/same-as.validator.ts +0 -27
  111. package/src/validators/skip-empty.validator.ts +0 -25
  112. package/tsconfig.json +0 -31
  113. package/tsconfig.lib.json +0 -16
  114. /package/{dist/.hygen → .hygen}/new/crud/controller.ejs.t +0 -0
  115. /package/{dist/.hygen → .hygen}/new/crud/create.dto.ejs.t +0 -0
  116. /package/{dist/.hygen → .hygen}/new/crud/entity.ejs.t +0 -0
  117. /package/{dist/.hygen → .hygen}/new/crud/get.dto.ejs.t +0 -0
  118. /package/{dist/.hygen → .hygen}/new/crud/index-dto.ejs.t +0 -0
  119. /package/{dist/.hygen → .hygen}/new/crud/index-response.dto.ejs.t +0 -0
  120. /package/{dist/.hygen → .hygen}/new/crud/module.ejs.t +0 -0
  121. /package/{dist/.hygen → .hygen}/new/crud/prompt.js +0 -0
  122. /package/{dist/.hygen → .hygen}/new/crud/service.ejs.t +0 -0
  123. /package/{dist/.hygen → .hygen}/new/crud/update.dto.ejs.t +0 -0
  124. /package/{dist/.hygen → .hygen}/new/module/controller.ejs.t +0 -0
  125. /package/{dist/.hygen → .hygen}/new/module/create-command.ejs.t +0 -0
  126. /package/{dist/.hygen → .hygen}/new/module/create.dto.ejs.t +0 -0
  127. /package/{dist/.hygen → .hygen}/new/module/dto.ejs.t +0 -0
  128. /package/{dist/.hygen → .hygen}/new/module/entity.ejs.t +0 -0
  129. /package/{dist/.hygen → .hygen}/new/module/get-query.ejs.t +0 -0
  130. /package/{dist/.hygen → .hygen}/new/module/module.ejs.t +0 -0
  131. /package/{dist/.hygen → .hygen}/new/module/not-found.exception.ejs.t +0 -0
  132. /package/{dist/.hygen → .hygen}/new/module/page-options.dto.ejs.t +0 -0
  133. /package/{dist/.hygen → .hygen}/new/module/prompt.js +0 -0
  134. /package/{dist/.hygen → .hygen}/new/module/repository.ejs.t +0 -0
  135. /package/{dist/.hygen → .hygen}/new/module/service.ejs.t +0 -0
  136. /package/{dist/.hygen → .hygen}/new/module/translation-dto.ejs.t +0 -0
  137. /package/{dist/.hygen → .hygen}/new/module/translation-entity.ejs.t +0 -0
  138. /package/{dist/.hygen → .hygen}/new/module/translation-repository.ejs.t +0 -0
  139. /package/{dist/.hygen → .hygen}/new/module/update.dto.ejs.t +0 -0
  140. /package/{dist/.hygen.js → .hygen.js} +0 -0
  141. /package/{dist/common → common}/abstract-client.service.d.ts +0 -0
  142. /package/{dist/common → common}/abstract-client.service.js +0 -0
  143. /package/{dist/common → common}/abstract.entity.d.ts +0 -0
  144. /package/{dist/common → common}/abstract.entity.js +0 -0
  145. /package/{dist/common → common}/boilerplate.polyfill.d.ts +0 -0
  146. /package/{dist/common → common}/boilerplate.polyfill.js +0 -0
  147. /package/{dist/common → common}/dto/abstract.dto.d.ts +0 -0
  148. /package/{dist/common → common}/dto/abstract.dto.js +0 -0
  149. /package/{dist/common → common}/dto/bulk-id.dto.d.ts +0 -0
  150. /package/{dist/common → common}/dto/bulk-id.dto.js +0 -0
  151. /package/{dist/common → common}/dto/create-translation.dto.d.ts +0 -0
  152. /package/{dist/common → common}/dto/create-translation.dto.js +0 -0
  153. /package/{dist/common → common}/dto/index.d.ts +0 -0
  154. /package/{dist/common → common}/dto/index.js +0 -0
  155. /package/{dist/common → common}/dto/page-meta.dto.d.ts +0 -0
  156. /package/{dist/common → common}/dto/page-meta.dto.js +0 -0
  157. /package/{dist/common → common}/dto/page-options.dto.d.ts +0 -0
  158. /package/{dist/common → common}/dto/page-options.dto.js +0 -0
  159. /package/{dist/common → common}/dto/page.dto.d.ts +0 -0
  160. /package/{dist/common → common}/dto/page.dto.js +0 -0
  161. /package/{dist/common → common}/index.d.ts +0 -0
  162. /package/{dist/common → common}/index.js +0 -0
  163. /package/{dist/common → common}/snake-naming.strategy.d.ts +0 -0
  164. /package/{dist/common → common}/snake-naming.strategy.js +0 -0
  165. /package/{dist/common → common}/types.d.ts +0 -0
  166. /package/{dist/common → common}/types.js +0 -0
  167. /package/{dist/common → common}/utils.d.ts +0 -0
  168. /package/{dist/common → common}/utils.js +0 -0
  169. /package/{dist/constants → constants}/index.d.ts +0 -0
  170. /package/{dist/constants → constants}/index.js +0 -0
  171. /package/{dist/constants → constants}/language-code.d.ts +0 -0
  172. /package/{dist/constants → constants}/language-code.js +0 -0
  173. /package/{dist/constants → constants}/order.d.ts +0 -0
  174. /package/{dist/constants → constants}/order.js +0 -0
  175. /package/{dist/decorators → decorators}/api-page-ok-response.decorator.d.ts +0 -0
  176. /package/{dist/decorators → decorators}/api-page-ok-response.decorator.js +0 -0
  177. /package/{dist/decorators → decorators}/auth-user.decorator.d.ts +0 -0
  178. /package/{dist/decorators → decorators}/auth-user.decorator.js +0 -0
  179. /package/{dist/decorators → decorators}/controller.decorator.d.ts +0 -0
  180. /package/{dist/decorators → decorators}/controller.decorator.js +0 -0
  181. /package/{dist/decorators → decorators}/field.decorators.d.ts +0 -0
  182. /package/{dist/decorators → decorators}/field.decorators.js +0 -0
  183. /package/{dist/decorators → decorators}/http.decorators.d.ts +0 -0
  184. /package/{dist/decorators → decorators}/http.decorators.js +0 -0
  185. /package/{dist/decorators → decorators}/index.d.ts +0 -0
  186. /package/{dist/decorators → decorators}/index.js +0 -0
  187. /package/{dist/decorators → decorators}/operation.decorator.d.ts +0 -0
  188. /package/{dist/decorators → decorators}/operation.decorator.js +0 -0
  189. /package/{dist/decorators → decorators}/property.decorators.d.ts +0 -0
  190. /package/{dist/decorators → decorators}/property.decorators.js +0 -0
  191. /package/{dist/decorators → decorators}/public-route.decorator.d.ts +0 -0
  192. /package/{dist/decorators → decorators}/public-route.decorator.js +0 -0
  193. /package/{dist/decorators → decorators}/swagger.schema.d.ts +0 -0
  194. /package/{dist/decorators → decorators}/swagger.schema.js +0 -0
  195. /package/{dist/decorators → decorators}/timestamp-column.decorator.d.ts +0 -0
  196. /package/{dist/decorators → decorators}/timestamp-column.decorator.js +0 -0
  197. /package/{dist/decorators → decorators}/transform.decorators.d.ts +0 -0
  198. /package/{dist/decorators → decorators}/transform.decorators.js +0 -0
  199. /package/{dist/decorators → decorators}/translate.decorator.d.ts +0 -0
  200. /package/{dist/decorators → decorators}/translate.decorator.js +0 -0
  201. /package/{dist/decorators → decorators}/use-dto.decorator.d.ts +0 -0
  202. /package/{dist/decorators → decorators}/use-dto.decorator.js +0 -0
  203. /package/{dist/decorators → decorators}/user-check.decorator.d.ts +0 -0
  204. /package/{dist/decorators → decorators}/user-check.decorator.js +0 -0
  205. /package/{dist/decorators → decorators}/user.decorator.d.ts +0 -0
  206. /package/{dist/decorators → decorators}/user.decorator.js +0 -0
  207. /package/{dist/decorators → decorators}/user_auth.decorator.d.ts +0 -0
  208. /package/{dist/decorators → decorators}/user_auth.decorator.js +0 -0
  209. /package/{dist/decorators → decorators}/validator.decorators.d.ts +0 -0
  210. /package/{dist/decorators → decorators}/validator.decorators.js +0 -0
  211. /package/{dist/exceptions → exceptions}/file-not-image.exception.d.ts +0 -0
  212. /package/{dist/exceptions → exceptions}/file-not-image.exception.js +0 -0
  213. /package/{dist/exceptions → exceptions}/index.d.ts +0 -0
  214. /package/{dist/exceptions → exceptions}/index.js +0 -0
  215. /package/{dist/exceptions → exceptions}/page-type.exception.d.ts +0 -0
  216. /package/{dist/exceptions → exceptions}/page-type.exception.js +0 -0
  217. /package/{dist/exceptions → exceptions}/user-not-found.exception.d.ts +0 -0
  218. /package/{dist/exceptions → exceptions}/user-not-found.exception.js +0 -0
  219. /package/{dist/filters → filters}/bad-request.filter.d.ts +0 -0
  220. /package/{dist/filters → filters}/bad-request.filter.js +0 -0
  221. /package/{dist/filters → filters}/constraint-errors.d.ts +0 -0
  222. /package/{dist/filters → filters}/constraint-errors.js +0 -0
  223. /package/{dist/filters → filters}/index.d.ts +0 -0
  224. /package/{dist/filters → filters}/index.js +0 -0
  225. /package/{dist/filters → filters}/query-failed.filter.d.ts +0 -0
  226. /package/{dist/filters → filters}/query-failed.filter.js +0 -0
  227. /package/{dist/health-checker → health-checker}/health-checker.controller.d.ts +0 -0
  228. /package/{dist/health-checker → health-checker}/health-checker.controller.js +0 -0
  229. /package/{dist/health-checker → health-checker}/health-checker.module.d.ts +0 -0
  230. /package/{dist/health-checker → health-checker}/health-checker.module.js +0 -0
  231. /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.d.ts +0 -0
  232. /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.js +0 -0
  233. /package/{dist/helpers → helpers}/common.helper.d.ts +0 -0
  234. /package/{dist/helpers → helpers}/common.helper.js +0 -0
  235. /package/{dist/helpers → helpers}/date.helper.d.ts +0 -0
  236. /package/{dist/helpers → helpers}/date.helper.js +0 -0
  237. /package/{dist/helpers → helpers}/index.d.ts +0 -0
  238. /package/{dist/helpers → helpers}/index.js +0 -0
  239. /package/{dist/i18n → i18n}/en_US/validation.json +0 -0
  240. /package/{dist/i18n → i18n}/zh_CN/validation.json +0 -0
  241. /package/{dist/index.d.ts → index.d.ts} +0 -0
  242. /package/{dist/index.js → index.js} +0 -0
  243. /package/{dist/interceptors → interceptors}/index.d.ts +0 -0
  244. /package/{dist/interceptors → interceptors}/index.js +0 -0
  245. /package/{dist/interceptors → interceptors}/language-interceptor.service.d.ts +0 -0
  246. /package/{dist/interceptors → interceptors}/language-interceptor.service.js +0 -0
  247. /package/{dist/interceptors → interceptors}/translation-interceptor.service.d.ts +0 -0
  248. /package/{dist/interceptors → interceptors}/translation-interceptor.service.js +0 -0
  249. /package/{dist/interfaces → interfaces}/IApiFile.d.ts +0 -0
  250. /package/{dist/interfaces → interfaces}/IApiFile.js +0 -0
  251. /package/{dist/interfaces → interfaces}/IFile.d.ts +0 -0
  252. /package/{dist/interfaces → interfaces}/IFile.js +0 -0
  253. /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.d.ts +0 -0
  254. /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.js +0 -0
  255. /package/{dist/interfaces → interfaces}/index.d.ts +0 -0
  256. /package/{dist/interfaces → interfaces}/index.js +0 -0
  257. /package/{dist/interfaces → interfaces}/response.d.ts +0 -0
  258. /package/{dist/interfaces → interfaces}/response.js +0 -0
  259. /package/{dist/middlewares → middlewares}/index.d.ts +0 -0
  260. /package/{dist/middlewares → middlewares}/index.js +0 -0
  261. /package/{dist/middlewares → middlewares}/omni-auth.middleware.d.ts +0 -0
  262. /package/{dist/middlewares → middlewares}/omni-auth.middleware.js +0 -0
  263. /package/{dist/middlewares → middlewares}/powerby.middleware.d.ts +0 -0
  264. /package/{dist/middlewares → middlewares}/powerby.middleware.js +0 -0
  265. /package/{dist/middlewares → middlewares}/request-id.middleware.d.ts +0 -0
  266. /package/{dist/middlewares → middlewares}/request-id.middleware.js +0 -0
  267. /package/{dist/middlewares → middlewares}/xml.middleware.d.ts +0 -0
  268. /package/{dist/middlewares → middlewares}/xml.middleware.js +0 -0
  269. /package/{dist/providers → providers}/context.provider.d.ts +0 -0
  270. /package/{dist/providers → providers}/context.provider.js +0 -0
  271. /package/{dist/providers → providers}/generator.provider.d.ts +0 -0
  272. /package/{dist/providers → providers}/generator.provider.js +0 -0
  273. /package/{dist/providers → providers}/index.d.ts +0 -0
  274. /package/{dist/providers → providers}/index.js +0 -0
  275. /package/{dist/setup → setup}/bootstrap.setup.d.ts +0 -0
  276. /package/{dist/setup → setup}/bootstrap.setup.js +0 -0
  277. /package/{dist/setup → setup}/index.d.ts +0 -0
  278. /package/{dist/setup → setup}/index.js +0 -0
  279. /package/{dist/shared → shared}/index.d.ts +0 -0
  280. /package/{dist/shared → shared}/index.js +0 -0
  281. /package/{dist/shared → shared}/serviceRegistryModule.d.ts +0 -0
  282. /package/{dist/shared → shared}/serviceRegistryModule.js +0 -0
  283. /package/{dist/shared → shared}/services/api-config.service.d.ts +0 -0
  284. /package/{dist/shared → shared}/services/api-config.service.js +0 -0
  285. /package/{dist/shared → shared}/services/generator.service.d.ts +0 -0
  286. /package/{dist/shared → shared}/services/generator.service.js +0 -0
  287. /package/{dist/shared → shared}/services/index.d.ts +0 -0
  288. /package/{dist/shared → shared}/services/index.js +0 -0
  289. /package/{dist/shared → shared}/services/translation.service.d.ts +0 -0
  290. /package/{dist/shared → shared}/services/translation.service.js +0 -0
  291. /package/{dist/shared → shared}/services/validator.service.d.ts +0 -0
  292. /package/{dist/shared → shared}/services/validator.service.js +0 -0
  293. /package/{dist/tsconfig.tsbuildinfo → tsconfig.tsbuildinfo} +0 -0
  294. /package/{dist/validator-json → validator-json}/decorators.d.ts +0 -0
  295. /package/{dist/validator-json → validator-json}/decorators.js +0 -0
  296. /package/{dist/validator-json → validator-json}/default.d.ts +0 -0
  297. /package/{dist/validator-json → validator-json}/default.js +0 -0
  298. /package/{dist/validator-json → validator-json}/defaultConverters.d.ts +0 -0
  299. /package/{dist/validator-json → validator-json}/defaultConverters.js +0 -0
  300. /package/{dist/validator-json → validator-json}/index.d.ts +0 -0
  301. /package/{dist/validator-json → validator-json}/index.js +0 -0
  302. /package/{dist/validator-json → validator-json}/options.d.ts +0 -0
  303. /package/{dist/validator-json → validator-json}/options.js +0 -0
  304. /package/{dist/validators → validators}/file-mimetype.validator.d.ts +0 -0
  305. /package/{dist/validators → validators}/file-mimetype.validator.js +0 -0
  306. /package/{dist/validators → validators}/index.d.ts +0 -0
  307. /package/{dist/validators → validators}/index.js +0 -0
  308. /package/{dist/validators → validators}/is-exists.validator.d.ts +0 -0
  309. /package/{dist/validators → validators}/is-exists.validator.js +0 -0
  310. /package/{dist/validators → validators}/is-unique.validator.d.ts +0 -0
  311. /package/{dist/validators → validators}/is-unique.validator.js +0 -0
  312. /package/{dist/validators → validators}/phone-country-code.validator.d.ts +0 -0
  313. /package/{dist/validators → validators}/phone-country-code.validator.js +0 -0
  314. /package/{dist/validators → validators}/same-as.validator.d.ts +0 -0
  315. /package/{dist/validators → validators}/same-as.validator.js +0 -0
  316. /package/{dist/validators → validators}/skip-empty.validator.d.ts +0 -0
  317. /package/{dist/validators → validators}/skip-empty.validator.js +0 -0
@@ -1,856 +0,0 @@
1
- import { applyDecorators } from '@nestjs/common';
2
- import type { ApiPropertyOptions } from '@nestjs/swagger';
3
- import { ApiProperty } from '@nestjs/swagger';
4
- import { i18nValidationMessage } from 'nestjs-i18n';
5
- import { Type } from 'class-transformer';
6
- import {
7
- ArrayMaxSize,
8
- ArrayMinSize,
9
- IsBoolean,
10
- IsDate,
11
- IsDefined,
12
- IsEmail,
13
- IsEnum,
14
- IsFQDN,
15
- IsInt,
16
- IsIP,
17
- IsLocale,
18
- IsNumber,
19
- IsObject,
20
- IsPositive,
21
- IsString,
22
- IsTimeZone,
23
- IsUrl,
24
- IsUUID,
25
- Max,
26
- MaxDate,
27
- MaxLength,
28
- Min,
29
- MinDate,
30
- MinLength,
31
- NotEquals,
32
- ValidateNested,
33
- } from 'class-validator';
34
-
35
- import { supportedLanguageCount } from '../constants';
36
- import { ApiEnumProperty, ApiUUIDProperty } from './property.decorators';
37
- import {
38
- PhoneNumberSerializer,
39
- ToArray,
40
- ToBoolean,
41
- ToLowerCase,
42
- ToUpperCase,
43
- } from './transform.decorators';
44
- import {
45
- IsEmptyable,
46
- IsHttpUrl,
47
- IsNullable,
48
- IsPhoneNumber,
49
- IsTmpKey as IsTemporaryKey,
50
- } from './validator.decorators';
51
- import * as ValidatorJS from 'validator';
52
-
53
- type RequireField<T, K extends keyof T> = T & Required<Pick<T, K>>;
54
-
55
- interface IFieldOptions {
56
- each?: boolean;
57
- swagger?: boolean;
58
- nullable?: boolean;
59
- group?: string[];
60
- message?: string;
61
- }
62
-
63
- interface INumberFieldOptions extends IFieldOptions {
64
- min?: number;
65
- max?: number;
66
- int?: boolean;
67
- isPositive?: boolean;
68
- }
69
-
70
- interface IDateFieldOptions extends IFieldOptions {
71
- minDate?: Date | (() => Date);
72
- maxDate?: Date | (() => Date);
73
- }
74
-
75
- interface IStringFieldOptions extends IFieldOptions {
76
- minLength?: number;
77
- maxLength?: number;
78
- toLowerCase?: boolean;
79
- toUpperCase?: boolean;
80
- }
81
-
82
- interface IEmailFieldOptions {
83
- emailOptions?: ValidatorJS.IsEmailOptions;
84
- }
85
-
86
- interface IIPFieldOptions {
87
- version?: ValidatorJS.IPVersion;
88
- }
89
-
90
- interface IURLFieldOptions {
91
- urlOptions?: ValidatorJS.IsURLOptions;
92
- simpleUrl?: boolean;
93
- }
94
-
95
- interface IFQDNFieldOptions extends ValidatorJS.IsFQDNOptions {}
96
-
97
- type IClassFieldOptions = IFieldOptions;
98
- type IBooleanFieldOptions = IFieldOptions;
99
- type IEnumFieldOptions = IFieldOptions;
100
-
101
- export function NumberField(
102
- options: Omit<ApiPropertyOptions, 'type'> & INumberFieldOptions = {},
103
- ): PropertyDecorator {
104
- const decorators = [Type(() => Number)];
105
-
106
- if (options.nullable) {
107
- decorators.push(
108
- IsNullable({
109
- each: options.each,
110
- }),
111
- );
112
- } else {
113
- decorators.push(
114
- NotEquals(null, {
115
- each: options.each,
116
- message: i18nValidationMessage('validation.NOT_EQUALS'),
117
- }),
118
- );
119
- }
120
-
121
- if (options.swagger !== false) {
122
- decorators.push(ApiProperty({ type: Number, ...options }));
123
- }
124
-
125
- if (options.each) {
126
- decorators.push(ToArray());
127
- }
128
-
129
- if (options.int) {
130
- decorators.push(
131
- IsInt({
132
- each: options.each,
133
- message: i18nValidationMessage('validation.IS_INT'),
134
- }),
135
- );
136
- } else {
137
- decorators.push(
138
- IsNumber(
139
- {},
140
- {
141
- each: options.each,
142
- message: i18nValidationMessage('validation.IS_NUMBER'),
143
- },
144
- ),
145
- );
146
- }
147
-
148
- if (typeof options.min === 'number') {
149
- decorators.push(
150
- Min(options.min, {
151
- each: options.each,
152
- message: i18nValidationMessage('validation.MIN'),
153
- }),
154
- );
155
- }
156
-
157
- if (typeof options.max === 'number') {
158
- decorators.push(
159
- Max(options.max, {
160
- each: options.each,
161
- message: i18nValidationMessage('validation.MAX'),
162
- }),
163
- );
164
- }
165
-
166
- if (options.isPositive) {
167
- decorators.push(
168
- IsPositive({
169
- each: options.each,
170
- message: i18nValidationMessage('validation.IS_POSITIVE'),
171
- }),
172
- );
173
- }
174
-
175
- return applyDecorators(...decorators);
176
- }
177
-
178
- export function NumberFieldOptional(
179
- options: Omit<ApiPropertyOptions, 'type' | 'required'> &
180
- INumberFieldOptions = {},
181
- ): PropertyDecorator {
182
- return applyDecorators(
183
- IsEmptyable(),
184
- NumberField({ required: false, ...options }),
185
- );
186
- }
187
-
188
- export function StringField(
189
- options: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions = {},
190
- ): PropertyDecorator {
191
- const decorators = [
192
- Type(() => String),
193
- IsString({
194
- each: options.each,
195
- message: i18nValidationMessage('validation.IS_STRING'),
196
- }),
197
- ];
198
-
199
- if (options.nullable) {
200
- decorators.push(IsNullable({ each: options.each }));
201
- } else {
202
- decorators.push(
203
- NotEquals(null, {
204
- each: options.each,
205
- message: i18nValidationMessage('validation.NOT_EQUALS'),
206
- }),
207
- );
208
- }
209
-
210
- if (options.swagger !== false) {
211
- decorators.push(
212
- ApiProperty({ type: String, ...options, isArray: options.each }),
213
- );
214
- }
215
-
216
- const minLength = options.minLength ?? 1;
217
-
218
- decorators.push(
219
- MinLength(minLength, {
220
- each: options.each,
221
- message: i18nValidationMessage('validation.MIN_LENGTH'),
222
- }),
223
- );
224
-
225
- if (options.maxLength) {
226
- decorators.push(
227
- MaxLength(options.maxLength, {
228
- each: options.each,
229
- message: i18nValidationMessage('validation.MAX_LENGTH'),
230
- }),
231
- );
232
- }
233
-
234
- if (options.toLowerCase) {
235
- decorators.push(ToLowerCase());
236
- }
237
-
238
- if (options.toUpperCase) {
239
- decorators.push(ToUpperCase());
240
- }
241
-
242
- return applyDecorators(...decorators);
243
- }
244
-
245
- export function StringFieldOptional(
246
- options: Omit<ApiPropertyOptions, 'type' | 'required'> &
247
- IStringFieldOptions = {},
248
- ): PropertyDecorator {
249
- return applyDecorators(
250
- IsEmptyable(),
251
- StringField({ required: false, ...options }),
252
- );
253
- }
254
-
255
- export function PasswordField(
256
- options: Omit<ApiPropertyOptions, 'type' | 'minLength'> &
257
- IStringFieldOptions = {},
258
- ): PropertyDecorator {
259
- const decorators = [
260
- StringField({ ...options, minLength: 6 }) /*IsPassword()*/,
261
- ];
262
-
263
- if (options.nullable) {
264
- decorators.push(IsNullable());
265
- } else {
266
- decorators.push(NotEquals(null));
267
- }
268
-
269
- return applyDecorators(...decorators);
270
- }
271
-
272
- export function PasswordFieldOptional(
273
- options: Omit<ApiPropertyOptions, 'type' | 'required' | 'minLength'> &
274
- IStringFieldOptions = {},
275
- ): PropertyDecorator {
276
- return applyDecorators(
277
- IsEmptyable(),
278
- PasswordField({ required: false, ...options }),
279
- );
280
- }
281
-
282
- export function BooleanField(
283
- options: Omit<ApiPropertyOptions, 'type'> & IBooleanFieldOptions = {},
284
- ): PropertyDecorator {
285
- const decorators = [
286
- ToBoolean(),
287
- IsBoolean({ message: 'validation.INVALID_BOOLEAN' }),
288
- ];
289
-
290
- if (options.nullable) {
291
- decorators.push(IsNullable());
292
- } else {
293
- decorators.push(NotEquals(null));
294
- }
295
-
296
- if (options.swagger !== false) {
297
- decorators.push(ApiProperty({ type: Boolean, ...options }));
298
- }
299
-
300
- return applyDecorators(...decorators);
301
- }
302
-
303
- export function BooleanFieldOptional(
304
- options: Omit<ApiPropertyOptions, 'type' | 'required'> &
305
- IBooleanFieldOptions = {},
306
- ): PropertyDecorator {
307
- return applyDecorators(
308
- IsEmptyable(),
309
- BooleanField({ required: false, ...options }),
310
- );
311
- }
312
-
313
- export function TranslationsField(
314
- options: RequireField<Omit<ApiPropertyOptions, 'isArray'>, 'type'> &
315
- IFieldOptions,
316
- ): PropertyDecorator {
317
- const decorators = [
318
- ArrayMinSize(supportedLanguageCount),
319
- ArrayMaxSize(supportedLanguageCount),
320
- ValidateNested({
321
- each: true,
322
- }),
323
- Type(() => options.type as FunctionConstructor),
324
- ];
325
-
326
- if (options.nullable) {
327
- decorators.push(IsNullable());
328
- } else {
329
- decorators.push(NotEquals(null));
330
- }
331
-
332
- if (options.swagger !== false) {
333
- decorators.push(ApiProperty({ isArray: true, ...options }));
334
- }
335
-
336
- return applyDecorators(...decorators);
337
- }
338
-
339
- export function TranslationsFieldOptional(
340
- options: RequireField<Omit<ApiPropertyOptions, 'isArray'>, 'type'> &
341
- IFieldOptions,
342
- ): PropertyDecorator {
343
- return applyDecorators(
344
- IsEmptyable(),
345
- TranslationsField({ required: false, ...options }),
346
- );
347
- }
348
-
349
- export function TmpKeyField(
350
- options: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions = {},
351
- ): PropertyDecorator {
352
- const decorators = [
353
- StringField(options),
354
- IsTemporaryKey({ each: options.each }),
355
- ];
356
-
357
- if (options.nullable) {
358
- decorators.push(IsNullable());
359
- } else {
360
- decorators.push(NotEquals(null));
361
- }
362
-
363
- if (options.swagger !== false) {
364
- decorators.push(
365
- ApiProperty({ type: String, ...options, isArray: options.each }),
366
- );
367
- }
368
-
369
- return applyDecorators(...decorators);
370
- }
371
-
372
- export function TmpKeyFieldOptional(
373
- options: Omit<ApiPropertyOptions, 'type' | 'required'> &
374
- IStringFieldOptions = {},
375
- ): PropertyDecorator {
376
- return applyDecorators(
377
- IsEmptyable(),
378
- TmpKeyField({ required: false, ...options }),
379
- );
380
- }
381
-
382
- export function getEnumDescription(enumType: any): string {
383
- const keys = Object.keys(enumType).filter(
384
- (k) => typeof enumType[k as any] === 'number',
385
- );
386
- return keys.map((k) => `${enumType[k]}: ${k}`).join(', ');
387
- }
388
-
389
- // eslint-disable-next-line @typescript-eslint/ban-types
390
- export function EnumField<TEnum extends object>(
391
- getEnum: () => TEnum,
392
- options: Omit<ApiPropertyOptions, 'type' | 'enum' | 'enumName' | 'isArray'> &
393
- IEnumFieldOptions = {},
394
- ): PropertyDecorator {
395
- // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/ban-types
396
- const enumValue = getEnum();
397
- const decorators = [
398
- IsEnum(enumValue, {
399
- each: options.each,
400
- message: i18nValidationMessage('validation.IS_ENUM'),
401
- }),
402
- ];
403
-
404
- if (options.nullable) {
405
- decorators.push(IsNullable());
406
- } else {
407
- decorators.push(NotEquals(null));
408
- }
409
-
410
- if (options.each) {
411
- decorators.push(ToArray());
412
- }
413
-
414
- if (options.swagger !== false) {
415
- decorators.push(
416
- ApiEnumProperty(getEnum, {
417
- ...options,
418
- isArray: options.each,
419
- }),
420
- );
421
- }
422
-
423
- return applyDecorators(...decorators);
424
- }
425
-
426
- // eslint-disable-next-line @typescript-eslint/ban-types
427
- export function ClassField<TClass extends object>(
428
- getClass: () => TClass,
429
- options: Omit<ApiPropertyOptions, 'type'> & IClassFieldOptions = {},
430
- ): PropertyDecorator {
431
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
432
- const classValue = getClass() as any;
433
-
434
- if (!classValue) {
435
- throw new Error('ClassField: recursive class definition');
436
- }
437
-
438
- const decorators = [
439
- Type(() => classValue),
440
- ValidateNested({ each: options.each }),
441
- ];
442
-
443
- if (options.required !== false) {
444
- decorators.push(IsDefined());
445
- }
446
-
447
- if (options.nullable) {
448
- decorators.push(IsNullable());
449
- } else {
450
- decorators.push(NotEquals(null));
451
- }
452
-
453
- if (options.swagger !== false) {
454
- decorators.push(
455
- ApiProperty({
456
- type: () => classValue,
457
- isArray: options.each,
458
- ...options,
459
- }),
460
- );
461
- }
462
-
463
- if (options.each) {
464
- decorators.push(ToArray());
465
- }
466
-
467
- return applyDecorators(...decorators);
468
- }
469
-
470
- // eslint-disable-next-line @typescript-eslint/ban-types
471
- export function EnumFieldOptional<TEnum extends object>(
472
- getEnum: () => TEnum,
473
- options: Omit<ApiPropertyOptions, 'type' | 'required' | 'enum' | 'enumName'> &
474
- IEnumFieldOptions = {},
475
- ): PropertyDecorator {
476
- return applyDecorators(
477
- IsEmptyable(),
478
- EnumField(getEnum, { required: false, ...options }),
479
- );
480
- }
481
-
482
- // eslint-disable-next-line @typescript-eslint/ban-types
483
- export function ClassFieldOptional<TClass extends object>(
484
- getClass: () => TClass,
485
- options: Omit<ApiPropertyOptions, 'type' | 'required'> &
486
- IClassFieldOptions = {},
487
- ): PropertyDecorator {
488
- return applyDecorators(
489
- IsEmptyable(),
490
- ClassField(getClass, { required: false, ...options }),
491
- );
492
- }
493
-
494
- export function EmailField(
495
- options: Omit<ApiPropertyOptions, 'type'> &
496
- IStringFieldOptions &
497
- IEmailFieldOptions = {},
498
- ): PropertyDecorator {
499
- const decorators = [
500
- IsEmail(options.emailOptions, {
501
- message:
502
- options.message ?? i18nValidationMessage('validation.INVALID_EMAIL'),
503
- ...options,
504
- }),
505
- StringField({ toLowerCase: true, ...options }),
506
- ];
507
-
508
- if (options.nullable) {
509
- decorators.push(IsNullable());
510
- } else {
511
- decorators.push(NotEquals(null));
512
- }
513
-
514
- if (options.swagger !== false) {
515
- decorators.push(ApiProperty({ type: String, ...options }));
516
- }
517
-
518
- return applyDecorators(...decorators);
519
- }
520
-
521
- export function EmailFieldOptional(
522
- options: Omit<ApiPropertyOptions, 'type'> &
523
- IStringFieldOptions &
524
- IEmailFieldOptions = {},
525
- ): PropertyDecorator {
526
- return applyDecorators(
527
- IsEmptyable(),
528
- EmailField({ required: false, ...options }),
529
- );
530
- }
531
-
532
- export function PhoneField(
533
- options: Omit<ApiPropertyOptions, 'type'> & IFieldOptions = {},
534
- ): PropertyDecorator {
535
- const decorators = [IsPhoneNumber(), PhoneNumberSerializer()];
536
-
537
- if (options.nullable) {
538
- decorators.push(IsNullable());
539
- } else {
540
- decorators.push(NotEquals(null));
541
- }
542
-
543
- if (options.swagger !== false) {
544
- decorators.push(ApiProperty({ type: String, ...options }));
545
- }
546
-
547
- return applyDecorators(...decorators);
548
- }
549
-
550
- export function PhoneFieldOptional(
551
- options: Omit<ApiPropertyOptions, 'type' | 'required'> & IFieldOptions = {},
552
- ): PropertyDecorator {
553
- return applyDecorators(
554
- IsEmptyable(),
555
- PhoneField({ required: false, ...options }),
556
- );
557
- }
558
-
559
- export function UUIDField(
560
- options: Omit<ApiPropertyOptions, 'type' | 'format' | 'isArray'> &
561
- IFieldOptions = {},
562
- ): PropertyDecorator {
563
- const decorators = [
564
- Type(() => String),
565
- IsUUID('4', {
566
- each: options.each,
567
- message: i18nValidationMessage('validation.IS_UUID'),
568
- }),
569
- ];
570
-
571
- if (options.nullable) {
572
- decorators.push(
573
- IsNullable({ message: i18nValidationMessage('validation.IS_NULLABLE') }),
574
- );
575
- } else {
576
- decorators.push(NotEquals(null));
577
- }
578
-
579
- if (options.swagger !== false) {
580
- decorators.push(ApiUUIDProperty(options));
581
- }
582
-
583
- if (options.each) {
584
- decorators.push(ToArray());
585
- }
586
-
587
- return applyDecorators(...decorators);
588
- }
589
-
590
- export function UUIDFieldOptional(
591
- options: Omit<ApiPropertyOptions, 'type' | 'required' | 'isArray'> &
592
- IFieldOptions = {},
593
- ): PropertyDecorator {
594
- return applyDecorators(
595
- IsEmptyable(),
596
- UUIDField({ required: false, ...options }),
597
- );
598
- }
599
-
600
- export function URLField(
601
- options: Omit<ApiPropertyOptions, 'type'> &
602
- IURLFieldOptions &
603
- IStringFieldOptions = {},
604
- ): PropertyDecorator {
605
- const decorators = [StringField({ ...options })];
606
- if (options.simpleUrl) {
607
- decorators.push(
608
- IsHttpUrl({
609
- each: options.each,
610
- message: i18nValidationMessage('validation.IS_URL'),
611
- }),
612
- );
613
- } else {
614
- decorators.push(
615
- IsUrl(options.urlOptions, {
616
- each: options.each,
617
- message: i18nValidationMessage('validation.IS_URL'),
618
- }),
619
- );
620
- }
621
-
622
- if (options.nullable) {
623
- decorators.push(IsNullable({ each: options.each }));
624
- } else {
625
- decorators.push(NotEquals(null, { each: options.each }));
626
- }
627
-
628
- return applyDecorators(...decorators);
629
- }
630
-
631
- export function URLFieldOptional(
632
- options: Omit<ApiPropertyOptions, 'type'> &
633
- IURLFieldOptions &
634
- IStringFieldOptions = {},
635
- ): PropertyDecorator {
636
- return applyDecorators(
637
- IsEmptyable(),
638
- URLField({ required: false, ...options }),
639
- );
640
- }
641
-
642
- export function FQDNField(
643
- options: Omit<ApiPropertyOptions, 'type'> &
644
- IFQDNFieldOptions &
645
- IStringFieldOptions = {},
646
- ): PropertyDecorator {
647
- const decorators = [
648
- IsFQDN(options, {
649
- each: options.each,
650
- message: i18nValidationMessage('validation.IS_FQDN'),
651
- }),
652
- StringField({ toLowerCase: true, ...options }),
653
- ];
654
-
655
- if (options.nullable) {
656
- decorators.push(IsNullable({ each: options.each }));
657
- } else {
658
- decorators.push(NotEquals(null, { each: options.each }));
659
- }
660
-
661
- return applyDecorators(...decorators);
662
- }
663
-
664
- export function FQDNFieldOptional(
665
- options: Omit<ApiPropertyOptions, 'type'> &
666
- IFQDNFieldOptions &
667
- IStringFieldOptions = {},
668
- ): PropertyDecorator {
669
- return applyDecorators(
670
- IsEmptyable(),
671
- FQDNField({ required: false, ...options }),
672
- );
673
- }
674
-
675
- export function DateField(
676
- options: Omit<ApiPropertyOptions, 'type'> & IDateFieldOptions = {},
677
- ): PropertyDecorator {
678
- const decorators = [
679
- Type(() => Date),
680
- IsDate({ message: i18nValidationMessage('validation.IS_DATE') }),
681
- ];
682
-
683
- if (options.nullable) {
684
- decorators.push(IsNullable());
685
- } else {
686
- decorators.push(NotEquals(null));
687
- }
688
-
689
- if (options.minDate) {
690
- decorators.push(
691
- MinDate(options.minDate, {
692
- each: options.each,
693
- message: i18nValidationMessage('validation.MIN_DATE'),
694
- }),
695
- );
696
- }
697
-
698
- if (options.maxDate) {
699
- decorators.push(
700
- MaxDate(options.maxDate, {
701
- each: options.each,
702
- message: i18nValidationMessage('validation.MAX_DATE'),
703
- }),
704
- );
705
- }
706
-
707
- if (options.swagger !== false) {
708
- decorators.push(ApiProperty({ type: Date, ...options }));
709
- }
710
-
711
- return applyDecorators(...decorators);
712
- }
713
-
714
- export function DateFieldOptional(
715
- options: Omit<ApiPropertyOptions, 'type' | 'required'> &
716
- IDateFieldOptions = {},
717
- ): PropertyDecorator {
718
- return applyDecorators(
719
- IsEmptyable(),
720
- DateField({ ...options, required: false }),
721
- );
722
- }
723
-
724
- export function IpFieldOptional(
725
- options: Omit<ApiPropertyOptions, 'type'> &
726
- IIPFieldOptions &
727
- IStringFieldOptions = {},
728
- ): PropertyDecorator {
729
- return applyDecorators(
730
- IsEmptyable(),
731
- IpField({ required: false, ...options }),
732
- );
733
- }
734
-
735
- export function IpField(
736
- options: Omit<ApiPropertyOptions, 'type'> &
737
- IStringFieldOptions &
738
- IIPFieldOptions,
739
- ): PropertyDecorator {
740
- const decorators = [
741
- IsIP(options.version || 4, {
742
- each: options.each,
743
- message: i18nValidationMessage('validation.IS_IP'),
744
- }),
745
- StringField({ toLowerCase: true, ...options }),
746
- ];
747
-
748
- if (options.nullable) {
749
- decorators.push(IsNullable({ each: options.each }));
750
- } else {
751
- decorators.push(NotEquals(null, { each: options.each }));
752
- }
753
-
754
- return applyDecorators(...decorators);
755
- }
756
-
757
- export function ObjectField(
758
- options: Omit<ApiPropertyOptions, 'type'> & IFieldOptions = {},
759
- ): PropertyDecorator {
760
- const decorators = [
761
- Type(() => Object),
762
- IsObject({
763
- each: options.each,
764
- message: i18nValidationMessage('validation.IS_OBJECT'),
765
- }),
766
- ];
767
-
768
- if (options.nullable) {
769
- decorators.push(IsNullable({ each: options.each }));
770
- } else {
771
- decorators.push(NotEquals(null, { each: options.each }));
772
- }
773
-
774
- if (options.swagger !== false) {
775
- decorators.push(
776
- ApiProperty({
777
- type: 'object',
778
- isArray: options.each,
779
- ...options,
780
- }),
781
- );
782
- }
783
-
784
- return applyDecorators(...decorators);
785
- }
786
-
787
- export function ObjectFieldOptional(
788
- options: Omit<ApiPropertyOptions, 'type'> & IFieldOptions = {},
789
- ): PropertyDecorator {
790
- return applyDecorators(
791
- IsEmptyable(),
792
- ObjectField({ required: false, ...options }),
793
- );
794
- }
795
-
796
- export function TimeZoneField(
797
- options: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions = {},
798
- ): PropertyDecorator {
799
- const decorators = [
800
- StringField({ ...options }),
801
- IsTimeZone({
802
- each: options.each,
803
- message: i18nValidationMessage('validation.IS_TIME_ZONE'),
804
- }),
805
- ];
806
-
807
- if (options.nullable) {
808
- decorators.push(IsNullable({ each: options.each }));
809
- } else {
810
- decorators.push(NotEquals(null, { each: options.each }));
811
- }
812
-
813
- return applyDecorators(...decorators);
814
- }
815
-
816
- export function TimeZoneFieldOptional(
817
- options: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions = {},
818
- ): PropertyDecorator {
819
- return applyDecorators(
820
- IsEmptyable(),
821
- TimeZoneField({ required: false, ...options }),
822
- );
823
- }
824
-
825
- export function LocaleField(
826
- options: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions = {},
827
- ): PropertyDecorator {
828
- const decorators = [
829
- StringField({ ...options }),
830
- IsLocale({
831
- each: options.each,
832
- message: i18nValidationMessage('validation.IS_LOCALE'),
833
- }),
834
- ];
835
-
836
- if (options.nullable) {
837
- decorators.push(IsNullable({ each: options.each }));
838
- } else {
839
- decorators.push(NotEquals(null, { each: options.each }));
840
- }
841
-
842
- if (options.swagger !== false) {
843
- decorators.push(ApiProperty({ type: String, ...options }));
844
- }
845
-
846
- return applyDecorators(...decorators);
847
- }
848
-
849
- export function LocaleFieldOptional(
850
- options: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions = {},
851
- ): PropertyDecorator {
852
- return applyDecorators(
853
- IsEmptyable(),
854
- LocaleField({ required: false, ...options }),
855
- );
856
- }