@wisemen/nestjs-custom-fields 0.0.0 → 0.0.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 (337) hide show
  1. package/LICENSE.md +59 -0
  2. package/README.md +279 -0
  3. package/dist/custom-field-choice.d.ts +6 -0
  4. package/dist/custom-field-choice.js +2 -0
  5. package/dist/custom-field-choice.js.map +1 -0
  6. package/dist/custom-field-definition.d.ts +41 -0
  7. package/dist/custom-field-definition.js +2 -0
  8. package/dist/custom-field-definition.js.map +1 -0
  9. package/dist/custom-field-definition.uuid.d.ts +7 -0
  10. package/dist/custom-field-definition.uuid.js +4 -0
  11. package/dist/custom-field-definition.uuid.js.map +1 -0
  12. package/dist/custom-field-rules.d.ts +28 -0
  13. package/dist/custom-field-rules.js +2 -0
  14. package/dist/custom-field-rules.js.map +1 -0
  15. package/dist/custom-field-type-contract.d.ts +38 -0
  16. package/dist/custom-field-type-contract.js +2 -0
  17. package/dist/custom-field-type-contract.js.map +1 -0
  18. package/dist/custom-field-types/boolean/boolean.contract.d.ts +8 -0
  19. package/dist/custom-field-types/boolean/boolean.contract.js +2 -0
  20. package/dist/custom-field-types/boolean/boolean.contract.js.map +1 -0
  21. package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.d.ts +1 -0
  22. package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.js +21 -0
  23. package/dist/custom-field-types/boolean/boolean.custom-field-definition.factory.unit.test.js.map +1 -0
  24. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.d.ts +1 -0
  25. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.js +2 -0
  26. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.js.map +1 -0
  27. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.d.ts +1 -0
  28. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.js +24 -0
  29. package/dist/custom-field-types/boolean/boolean.custom-field-value.validator.unit.test.js.map +1 -0
  30. package/dist/custom-field-types/boolean/boolean.definition-validation.d.ts +7 -0
  31. package/dist/custom-field-types/boolean/boolean.definition-validation.js +10 -0
  32. package/dist/custom-field-types/boolean/boolean.definition-validation.js.map +1 -0
  33. package/dist/custom-field-types/boolean/boolean.dto.d.ts +9 -0
  34. package/dist/custom-field-types/boolean/boolean.dto.js +33 -0
  35. package/dist/custom-field-types/boolean/boolean.dto.js.map +1 -0
  36. package/dist/custom-field-types/boolean/boolean.rules.d.ts +5 -0
  37. package/dist/custom-field-types/boolean/boolean.rules.js +2 -0
  38. package/dist/custom-field-types/boolean/boolean.rules.js.map +1 -0
  39. package/dist/custom-field-types/boolean/boolean.value.d.ts +5 -0
  40. package/dist/custom-field-types/boolean/boolean.value.js +2 -0
  41. package/dist/custom-field-types/boolean/boolean.value.js.map +1 -0
  42. package/dist/custom-field-types/boolean/index.d.ts +6 -0
  43. package/dist/custom-field-types/boolean/index.js +7 -0
  44. package/dist/custom-field-types/boolean/index.js.map +1 -0
  45. package/dist/custom-field-types/date/date.contract.d.ts +12 -0
  46. package/dist/custom-field-types/date/date.contract.js +2 -0
  47. package/dist/custom-field-types/date/date.contract.js.map +1 -0
  48. package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.d.ts +1 -0
  49. package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.js +70 -0
  50. package/dist/custom-field-types/date/date.custom-field-definition.factory.unit.test.js.map +1 -0
  51. package/dist/custom-field-types/date/date.custom-field-value.validator.d.ts +6 -0
  52. package/dist/custom-field-types/date/date.custom-field-value.validator.js +14 -0
  53. package/dist/custom-field-types/date/date.custom-field-value.validator.js.map +1 -0
  54. package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.d.ts +1 -0
  55. package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.js +47 -0
  56. package/dist/custom-field-types/date/date.custom-field-value.validator.unit.test.js.map +1 -0
  57. package/dist/custom-field-types/date/date.definition-validation.d.ts +7 -0
  58. package/dist/custom-field-types/date/date.definition-validation.js +35 -0
  59. package/dist/custom-field-types/date/date.definition-validation.js.map +1 -0
  60. package/dist/custom-field-types/date/date.dto.d.ts +9 -0
  61. package/dist/custom-field-types/date/date.dto.js +34 -0
  62. package/dist/custom-field-types/date/date.dto.js.map +1 -0
  63. package/dist/custom-field-types/date/date.rules.d.ts +5 -0
  64. package/dist/custom-field-types/date/date.rules.js +2 -0
  65. package/dist/custom-field-types/date/date.rules.js.map +1 -0
  66. package/dist/custom-field-types/date/date.value.d.ts +5 -0
  67. package/dist/custom-field-types/date/date.value.js +2 -0
  68. package/dist/custom-field-types/date/date.value.js.map +1 -0
  69. package/dist/custom-field-types/date/index.d.ts +6 -0
  70. package/dist/custom-field-types/date/index.js +7 -0
  71. package/dist/custom-field-types/date/index.js.map +1 -0
  72. package/dist/custom-field-types/index.d.ts +9 -0
  73. package/dist/custom-field-types/index.js +10 -0
  74. package/dist/custom-field-types/index.js.map +1 -0
  75. package/dist/custom-field-types/monetary/index.d.ts +6 -0
  76. package/dist/custom-field-types/monetary/index.js +7 -0
  77. package/dist/custom-field-types/monetary/index.js.map +1 -0
  78. package/dist/custom-field-types/monetary/monetary.contract.d.ts +14 -0
  79. package/dist/custom-field-types/monetary/monetary.contract.js +2 -0
  80. package/dist/custom-field-types/monetary/monetary.contract.js.map +1 -0
  81. package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.d.ts +1 -0
  82. package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.js +98 -0
  83. package/dist/custom-field-types/monetary/monetary.custom-field-definition.factory.unit.test.js.map +1 -0
  84. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.d.ts +6 -0
  85. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.js +27 -0
  86. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.js.map +1 -0
  87. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.d.ts +1 -0
  88. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.js +130 -0
  89. package/dist/custom-field-types/monetary/monetary.custom-field-value.validator.unit.test.js.map +1 -0
  90. package/dist/custom-field-types/monetary/monetary.definition-validation.d.ts +7 -0
  91. package/dist/custom-field-types/monetary/monetary.definition-validation.js +25 -0
  92. package/dist/custom-field-types/monetary/monetary.definition-validation.js.map +1 -0
  93. package/dist/custom-field-types/monetary/monetary.dto.d.ts +10 -0
  94. package/dist/custom-field-types/monetary/monetary.dto.js +34 -0
  95. package/dist/custom-field-types/monetary/monetary.dto.js.map +1 -0
  96. package/dist/custom-field-types/monetary/monetary.rules.d.ts +5 -0
  97. package/dist/custom-field-types/monetary/monetary.rules.js +2 -0
  98. package/dist/custom-field-types/monetary/monetary.rules.js.map +1 -0
  99. package/dist/custom-field-types/monetary/monetary.value.d.ts +5 -0
  100. package/dist/custom-field-types/monetary/monetary.value.js +2 -0
  101. package/dist/custom-field-types/monetary/monetary.value.js.map +1 -0
  102. package/dist/custom-field-types/multi-select/index.d.ts +6 -0
  103. package/dist/custom-field-types/multi-select/index.js +7 -0
  104. package/dist/custom-field-types/multi-select/index.js.map +1 -0
  105. package/dist/custom-field-types/multi-select/multi-select.contract.d.ts +11 -0
  106. package/dist/custom-field-types/multi-select/multi-select.contract.js +2 -0
  107. package/dist/custom-field-types/multi-select/multi-select.contract.js.map +1 -0
  108. package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.d.ts +1 -0
  109. package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.js +169 -0
  110. package/dist/custom-field-types/multi-select/multi-select.custom-field-definition.factory.unit.test.js.map +1 -0
  111. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.d.ts +5 -0
  112. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.js +25 -0
  113. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.js.map +1 -0
  114. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.d.ts +1 -0
  115. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.js +122 -0
  116. package/dist/custom-field-types/multi-select/multi-select.custom-field-value.validator.unit.test.js.map +1 -0
  117. package/dist/custom-field-types/multi-select/multi-select.definition-validation.d.ts +7 -0
  118. package/dist/custom-field-types/multi-select/multi-select.definition-validation.js +45 -0
  119. package/dist/custom-field-types/multi-select/multi-select.definition-validation.js.map +1 -0
  120. package/dist/custom-field-types/multi-select/multi-select.dto.d.ts +9 -0
  121. package/dist/custom-field-types/multi-select/multi-select.dto.js +36 -0
  122. package/dist/custom-field-types/multi-select/multi-select.dto.js.map +1 -0
  123. package/dist/custom-field-types/multi-select/multi-select.rules.d.ts +5 -0
  124. package/dist/custom-field-types/multi-select/multi-select.rules.js +2 -0
  125. package/dist/custom-field-types/multi-select/multi-select.rules.js.map +1 -0
  126. package/dist/custom-field-types/multi-select/multi-select.value.d.ts +5 -0
  127. package/dist/custom-field-types/multi-select/multi-select.value.js +2 -0
  128. package/dist/custom-field-types/multi-select/multi-select.value.js.map +1 -0
  129. package/dist/custom-field-types/number/index.d.ts +6 -0
  130. package/dist/custom-field-types/number/index.js +7 -0
  131. package/dist/custom-field-types/number/index.js.map +1 -0
  132. package/dist/custom-field-types/number/number.contract.d.ts +11 -0
  133. package/dist/custom-field-types/number/number.contract.js +2 -0
  134. package/dist/custom-field-types/number/number.contract.js.map +1 -0
  135. package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.d.ts +1 -0
  136. package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.js +44 -0
  137. package/dist/custom-field-types/number/number.custom-field-definition.factory.unit.test.js.map +1 -0
  138. package/dist/custom-field-types/number/number.custom-field-value.validator.d.ts +5 -0
  139. package/dist/custom-field-types/number/number.custom-field-value.validator.js +14 -0
  140. package/dist/custom-field-types/number/number.custom-field-value.validator.js.map +1 -0
  141. package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.d.ts +1 -0
  142. package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.js +46 -0
  143. package/dist/custom-field-types/number/number.custom-field-value.validator.unit.test.js.map +1 -0
  144. package/dist/custom-field-types/number/number.definition-validation.d.ts +7 -0
  145. package/dist/custom-field-types/number/number.definition-validation.js +16 -0
  146. package/dist/custom-field-types/number/number.definition-validation.js.map +1 -0
  147. package/dist/custom-field-types/number/number.dto.d.ts +9 -0
  148. package/dist/custom-field-types/number/number.dto.js +33 -0
  149. package/dist/custom-field-types/number/number.dto.js.map +1 -0
  150. package/dist/custom-field-types/number/number.rules.d.ts +5 -0
  151. package/dist/custom-field-types/number/number.rules.js +2 -0
  152. package/dist/custom-field-types/number/number.rules.js.map +1 -0
  153. package/dist/custom-field-types/number/number.value.d.ts +5 -0
  154. package/dist/custom-field-types/number/number.value.js +2 -0
  155. package/dist/custom-field-types/number/number.value.js.map +1 -0
  156. package/dist/custom-field-types/single-select/index.d.ts +6 -0
  157. package/dist/custom-field-types/single-select/index.js +7 -0
  158. package/dist/custom-field-types/single-select/index.js.map +1 -0
  159. package/dist/custom-field-types/single-select/single-select.contract.d.ts +8 -0
  160. package/dist/custom-field-types/single-select/single-select.contract.js +2 -0
  161. package/dist/custom-field-types/single-select/single-select.contract.js.map +1 -0
  162. package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.d.ts +1 -0
  163. package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.js +100 -0
  164. package/dist/custom-field-types/single-select/single-select.custom-field-definition.factory.unit.test.js.map +1 -0
  165. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.d.ts +5 -0
  166. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.js +10 -0
  167. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.js.map +1 -0
  168. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.d.ts +1 -0
  169. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.js +57 -0
  170. package/dist/custom-field-types/single-select/single-select.custom-field-value.validator.unit.test.js.map +1 -0
  171. package/dist/custom-field-types/single-select/single-select.definition-validation.d.ts +7 -0
  172. package/dist/custom-field-types/single-select/single-select.definition-validation.js +25 -0
  173. package/dist/custom-field-types/single-select/single-select.definition-validation.js.map +1 -0
  174. package/dist/custom-field-types/single-select/single-select.dto.d.ts +9 -0
  175. package/dist/custom-field-types/single-select/single-select.dto.js +34 -0
  176. package/dist/custom-field-types/single-select/single-select.dto.js.map +1 -0
  177. package/dist/custom-field-types/single-select/single-select.rules.d.ts +5 -0
  178. package/dist/custom-field-types/single-select/single-select.rules.js +2 -0
  179. package/dist/custom-field-types/single-select/single-select.rules.js.map +1 -0
  180. package/dist/custom-field-types/single-select/single-select.value.d.ts +5 -0
  181. package/dist/custom-field-types/single-select/single-select.value.js +2 -0
  182. package/dist/custom-field-types/single-select/single-select.value.js.map +1 -0
  183. package/dist/custom-field-types/text/index.d.ts +6 -0
  184. package/dist/custom-field-types/text/index.js +7 -0
  185. package/dist/custom-field-types/text/index.js.map +1 -0
  186. package/dist/custom-field-types/text/text.contract.d.ts +12 -0
  187. package/dist/custom-field-types/text/text.contract.js +2 -0
  188. package/dist/custom-field-types/text/text.contract.js.map +1 -0
  189. package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.d.ts +1 -0
  190. package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.js +128 -0
  191. package/dist/custom-field-types/text/text.custom-field-definition.factory.unit.test.js.map +1 -0
  192. package/dist/custom-field-types/text/text.custom-field-value.validator.d.ts +5 -0
  193. package/dist/custom-field-types/text/text.custom-field-value.validator.js +17 -0
  194. package/dist/custom-field-types/text/text.custom-field-value.validator.js.map +1 -0
  195. package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.d.ts +1 -0
  196. package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.js +64 -0
  197. package/dist/custom-field-types/text/text.custom-field-value.validator.unit.test.js.map +1 -0
  198. package/dist/custom-field-types/text/text.definition-validation.d.ts +7 -0
  199. package/dist/custom-field-types/text/text.definition-validation.js +30 -0
  200. package/dist/custom-field-types/text/text.definition-validation.js.map +1 -0
  201. package/dist/custom-field-types/text/text.dto.d.ts +9 -0
  202. package/dist/custom-field-types/text/text.dto.js +33 -0
  203. package/dist/custom-field-types/text/text.dto.js.map +1 -0
  204. package/dist/custom-field-types/text/text.rules.d.ts +5 -0
  205. package/dist/custom-field-types/text/text.rules.js +2 -0
  206. package/dist/custom-field-types/text/text.rules.js.map +1 -0
  207. package/dist/custom-field-types/text/text.value.d.ts +5 -0
  208. package/dist/custom-field-types/text/text.value.js +2 -0
  209. package/dist/custom-field-types/text/text.value.js.map +1 -0
  210. package/dist/custom-field-types/text-array/index.d.ts +6 -0
  211. package/dist/custom-field-types/text-array/index.js +7 -0
  212. package/dist/custom-field-types/text-array/index.js.map +1 -0
  213. package/dist/custom-field-types/text-array/text-array.contract.d.ts +11 -0
  214. package/dist/custom-field-types/text-array/text-array.contract.js +2 -0
  215. package/dist/custom-field-types/text-array/text-array.contract.js.map +1 -0
  216. package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.d.ts +1 -0
  217. package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.js +71 -0
  218. package/dist/custom-field-types/text-array/text-array.custom-field-definition.factory.unit.test.js.map +1 -0
  219. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.d.ts +5 -0
  220. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.js +14 -0
  221. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.js.map +1 -0
  222. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.d.ts +1 -0
  223. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js +46 -0
  224. package/dist/custom-field-types/text-array/text-array.custom-field-value.validator.unit.test.js.map +1 -0
  225. package/dist/custom-field-types/text-array/text-array.definition-validation.d.ts +7 -0
  226. package/dist/custom-field-types/text-array/text-array.definition-validation.js +22 -0
  227. package/dist/custom-field-types/text-array/text-array.definition-validation.js.map +1 -0
  228. package/dist/custom-field-types/text-array/text-array.dto.d.ts +9 -0
  229. package/dist/custom-field-types/text-array/text-array.dto.js +36 -0
  230. package/dist/custom-field-types/text-array/text-array.dto.js.map +1 -0
  231. package/dist/custom-field-types/text-array/text-array.rules.d.ts +5 -0
  232. package/dist/custom-field-types/text-array/text-array.rules.js +2 -0
  233. package/dist/custom-field-types/text-array/text-array.rules.js.map +1 -0
  234. package/dist/custom-field-types/text-array/text-array.value.d.ts +5 -0
  235. package/dist/custom-field-types/text-array/text-array.value.js +2 -0
  236. package/dist/custom-field-types/text-array/text-array.value.js.map +1 -0
  237. package/dist/custom-field-types/timestamp/index.d.ts +6 -0
  238. package/dist/custom-field-types/timestamp/index.js +7 -0
  239. package/dist/custom-field-types/timestamp/index.js.map +1 -0
  240. package/dist/custom-field-types/timestamp/timestamp.contract.d.ts +12 -0
  241. package/dist/custom-field-types/timestamp/timestamp.contract.js +2 -0
  242. package/dist/custom-field-types/timestamp/timestamp.contract.js.map +1 -0
  243. package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.d.ts +1 -0
  244. package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js +70 -0
  245. package/dist/custom-field-types/timestamp/timestamp.custom-field-definition.factory.unit.test.js.map +1 -0
  246. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.d.ts +6 -0
  247. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.js +14 -0
  248. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.js.map +1 -0
  249. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.d.ts +1 -0
  250. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.js +47 -0
  251. package/dist/custom-field-types/timestamp/timestamp.custom-field-value.validator.unit.test.js.map +1 -0
  252. package/dist/custom-field-types/timestamp/timestamp.definition-validation.d.ts +7 -0
  253. package/dist/custom-field-types/timestamp/timestamp.definition-validation.js +38 -0
  254. package/dist/custom-field-types/timestamp/timestamp.definition-validation.js.map +1 -0
  255. package/dist/custom-field-types/timestamp/timestamp.dto.d.ts +9 -0
  256. package/dist/custom-field-types/timestamp/timestamp.dto.js +35 -0
  257. package/dist/custom-field-types/timestamp/timestamp.dto.js.map +1 -0
  258. package/dist/custom-field-types/timestamp/timestamp.rules.d.ts +5 -0
  259. package/dist/custom-field-types/timestamp/timestamp.rules.js +2 -0
  260. package/dist/custom-field-types/timestamp/timestamp.rules.js.map +1 -0
  261. package/dist/custom-field-types/timestamp/timestamp.value.d.ts +5 -0
  262. package/dist/custom-field-types/timestamp/timestamp.value.js +2 -0
  263. package/dist/custom-field-types/timestamp/timestamp.value.js.map +1 -0
  264. package/dist/custom-field-value.d.ts +17 -0
  265. package/dist/custom-field-value.js +2 -0
  266. package/dist/custom-field-value.js.map +1 -0
  267. package/dist/decorators/is-custom-fields.decorator.d.ts +1 -0
  268. package/dist/decorators/is-custom-fields.decorator.js +14 -0
  269. package/dist/decorators/is-custom-fields.decorator.js.map +1 -0
  270. package/dist/dto/base-custom-field-value.dto.d.ts +15 -0
  271. package/dist/dto/base-custom-field-value.dto.js +33 -0
  272. package/dist/dto/base-custom-field-value.dto.js.map +1 -0
  273. package/dist/dto/custom-field-value.dto.d.ts +46 -0
  274. package/dist/dto/custom-field-value.dto.js +72 -0
  275. package/dist/dto/custom-field-value.dto.js.map +1 -0
  276. package/dist/dto/custom-field-value.dto.unit.test.d.ts +1 -0
  277. package/dist/dto/custom-field-value.dto.unit.test.js +74 -0
  278. package/dist/dto/custom-field-value.dto.unit.test.js.map +1 -0
  279. package/dist/enum/custom-field-type.enum.d.ts +15 -0
  280. package/dist/enum/custom-field-type.enum.js +28 -0
  281. package/dist/enum/custom-field-type.enum.js.map +1 -0
  282. package/dist/errors/custom-field-definition.error.d.ts +2 -0
  283. package/dist/errors/custom-field-definition.error.js +3 -0
  284. package/dist/errors/custom-field-definition.error.js.map +1 -0
  285. package/dist/exhaustive-check.d.ts +1 -0
  286. package/dist/exhaustive-check.js +4 -0
  287. package/dist/exhaustive-check.js.map +1 -0
  288. package/dist/factory/custom-field-definition.factory.d.ts +41 -0
  289. package/dist/factory/custom-field-definition.factory.js +125 -0
  290. package/dist/factory/custom-field-definition.factory.js.map +1 -0
  291. package/dist/index.d.ts +18 -0
  292. package/dist/index.js +17 -0
  293. package/dist/index.js.map +1 -0
  294. package/dist/repositories/custom-field-definition.repository.module.d.ts +2 -0
  295. package/dist/repositories/custom-field-definition.repository.module.js +27 -0
  296. package/dist/repositories/custom-field-definition.repository.module.js.map +1 -0
  297. package/dist/repositories/custom-field-definitions.repository.d.ts +11 -0
  298. package/dist/repositories/custom-field-definitions.repository.integration.test.d.ts +1 -0
  299. package/dist/repositories/custom-field-definitions.repository.integration.test.js +174 -0
  300. package/dist/repositories/custom-field-definitions.repository.integration.test.js.map +1 -0
  301. package/dist/repositories/custom-field-definitions.repository.js +40 -0
  302. package/dist/repositories/custom-field-definitions.repository.js.map +1 -0
  303. package/dist/repositories/index.d.ts +2 -0
  304. package/dist/repositories/index.js +3 -0
  305. package/dist/repositories/index.js.map +1 -0
  306. package/dist/responses/custom-field-definition.response.d.ts +26 -0
  307. package/dist/responses/custom-field-definition.response.js +99 -0
  308. package/dist/responses/custom-field-definition.response.js.map +1 -0
  309. package/dist/responses/custom-field-definition.response.unit.test.d.ts +1 -0
  310. package/dist/responses/custom-field-definition.response.unit.test.js +96 -0
  311. package/dist/responses/custom-field-definition.response.unit.test.js.map +1 -0
  312. package/dist/tests/sql/datasource.d.ts +2 -0
  313. package/dist/tests/sql/datasource.js +17 -0
  314. package/dist/tests/sql/datasource.js.map +1 -0
  315. package/dist/tests/test-setup.d.ts +8 -0
  316. package/dist/tests/test-setup.js +46 -0
  317. package/dist/tests/test-setup.js.map +1 -0
  318. package/dist/typeorm/custom-field-choice.column.d.ts +2 -0
  319. package/dist/typeorm/custom-field-choice.column.js +49 -0
  320. package/dist/typeorm/custom-field-choice.column.js.map +1 -0
  321. package/dist/typeorm/custom-field-definition.entity.d.ts +20 -0
  322. package/dist/typeorm/custom-field-definition.entity.js +82 -0
  323. package/dist/typeorm/custom-field-definition.entity.js.map +1 -0
  324. package/dist/typeorm/custom-field-value.column.d.ts +2 -0
  325. package/dist/typeorm/custom-field-value.column.js +102 -0
  326. package/dist/typeorm/custom-field-value.column.js.map +1 -0
  327. package/dist/validators/custom-field-value-validation.error.d.ts +6 -0
  328. package/dist/validators/custom-field-value-validation.error.js +22 -0
  329. package/dist/validators/custom-field-value-validation.error.js.map +1 -0
  330. package/dist/validators/custom-field-value.validator.d.ts +4 -0
  331. package/dist/validators/custom-field-value.validator.js +81 -0
  332. package/dist/validators/custom-field-value.validator.js.map +1 -0
  333. package/dist/validators/custom-field-value.validator.unit.test.d.ts +1 -0
  334. package/dist/validators/custom-field-value.validator.unit.test.js +166 -0
  335. package/dist/validators/custom-field-value.validator.unit.test.js.map +1 -0
  336. package/package.json +56 -3
  337. package/skills/getting-started/SKILL.md +263 -0
@@ -0,0 +1,166 @@
1
+ import { describe, it } from 'node:test';
2
+ import { LocalizedString } from '@wisemen/localized-string';
3
+ import { customFieldDefinition } from '#src/factory/custom-field-definition.factory.js';
4
+ import { CustomFieldType } from '#src/enum/custom-field-type.enum.js';
5
+ import { validateCustomFieldValue, validateCustomFieldValues } from '#src/validators/custom-field-value.validator.js';
6
+ import { generateUuid } from '#src/custom-field-definition.uuid.js';
7
+ import { CustomFieldValueValidationError } from '#src/validators/custom-field-value-validation.error.js';
8
+ import { expect } from 'expect';
9
+ describe('validateCustomFieldValues', () => {
10
+ it('accepts valid custom field values', () => {
11
+ const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
12
+ tenantUuid: null,
13
+ entityType: 'invoice',
14
+ key: 'notes',
15
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
16
+ description: null,
17
+ isRequired: true,
18
+ rules: {
19
+ minLength: 2
20
+ }
21
+ });
22
+ const singleSelectDefinition = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
23
+ tenantUuid: null,
24
+ entityType: 'invoice',
25
+ key: 'status',
26
+ label: new LocalizedString([{ locale: 'en', value: 'Status' }]),
27
+ description: null,
28
+ isRequired: false,
29
+ choices: [
30
+ {
31
+ value: 'draft',
32
+ label: new LocalizedString([{ locale: 'en', value: 'Draft' }]),
33
+ order: 1
34
+ }
35
+ ]
36
+ });
37
+ expect(() => validateCustomFieldValues([textDefinition, singleSelectDefinition], [
38
+ {
39
+ definitionUuid: textDefinition.uuid,
40
+ type: CustomFieldType.TEXT,
41
+ value: 'ok'
42
+ },
43
+ {
44
+ definitionUuid: singleSelectDefinition.uuid,
45
+ type: CustomFieldType.SINGLE_SELECT,
46
+ value: 'draft'
47
+ }
48
+ ])).not.toThrow();
49
+ });
50
+ it('rejects duplicate custom field definitions', () => {
51
+ const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
52
+ tenantUuid: null,
53
+ entityType: 'invoice',
54
+ key: 'notes',
55
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
56
+ description: null,
57
+ isRequired: false
58
+ });
59
+ expect(() => validateCustomFieldValues([textDefinition, textDefinition], [])).toThrow(new CustomFieldValueValidationError(`Duplicate custom field definition ${textDefinition.uuid}`));
60
+ });
61
+ it('rejects a value whose definition was not provided', () => {
62
+ const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
63
+ tenantUuid: null,
64
+ entityType: 'invoice',
65
+ key: 'notes',
66
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
67
+ description: null,
68
+ isRequired: false
69
+ });
70
+ const missingDefinitionUuid = generateUuid();
71
+ expect(() => validateCustomFieldValues([textDefinition], [
72
+ {
73
+ definitionUuid: missingDefinitionUuid,
74
+ type: CustomFieldType.TEXT,
75
+ value: 'hello'
76
+ }
77
+ ])).toThrow(new CustomFieldValueValidationError(`Custom field definition ${missingDefinitionUuid} was not found`));
78
+ });
79
+ it('rejects duplicate values for the same definition', () => {
80
+ const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
81
+ tenantUuid: null,
82
+ entityType: 'invoice',
83
+ key: 'notes',
84
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
85
+ description: null,
86
+ isRequired: false
87
+ });
88
+ expect(() => validateCustomFieldValues([textDefinition], [
89
+ {
90
+ definitionUuid: textDefinition.uuid,
91
+ type: CustomFieldType.TEXT,
92
+ value: 'first'
93
+ },
94
+ {
95
+ definitionUuid: textDefinition.uuid,
96
+ type: CustomFieldType.TEXT,
97
+ value: 'second'
98
+ }
99
+ ])).toThrow(new CustomFieldValueValidationError(`Custom field value for definition ${textDefinition.uuid} can only be provided once`));
100
+ });
101
+ it('rejects when a required custom field is missing', () => {
102
+ const textDefinition = customFieldDefinition(CustomFieldType.TEXT, {
103
+ tenantUuid: null,
104
+ entityType: 'invoice',
105
+ key: 'notes',
106
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
107
+ description: null,
108
+ isRequired: true
109
+ });
110
+ expect(() => validateCustomFieldValues([textDefinition], [])).toThrow(new CustomFieldValueValidationError(`Custom field definition ${textDefinition.uuid} is required`));
111
+ });
112
+ });
113
+ describe('validateCustomFieldValue', () => {
114
+ it('rejects when definitionUuid does not match the definition', () => {
115
+ const definition = customFieldDefinition(CustomFieldType.TEXT, {
116
+ tenantUuid: null,
117
+ entityType: 'invoice',
118
+ key: 'notes',
119
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
120
+ description: null,
121
+ isRequired: false
122
+ });
123
+ expect(() => validateCustomFieldValue(definition, {
124
+ definitionUuid: generateUuid(),
125
+ type: CustomFieldType.TEXT,
126
+ value: 'hello'
127
+ })).toThrow(new CustomFieldValueValidationError('Custom field value definitionUuid must match the definition uuid'));
128
+ });
129
+ it('rejects when value type does not match the definition type', () => {
130
+ const definition = customFieldDefinition(CustomFieldType.TEXT, {
131
+ tenantUuid: null,
132
+ entityType: 'invoice',
133
+ key: 'notes',
134
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
135
+ description: null,
136
+ isRequired: false
137
+ });
138
+ expect(() => validateCustomFieldValue(definition, {
139
+ definitionUuid: definition.uuid,
140
+ type: CustomFieldType.NUMBER,
141
+ value: 1
142
+ })).toThrow(new CustomFieldValueValidationError('Custom field value type must match the definition type'));
143
+ });
144
+ it('rejects when the rules type does not match the definition type', () => {
145
+ const definition = {
146
+ ...customFieldDefinition(CustomFieldType.TEXT, {
147
+ tenantUuid: null,
148
+ entityType: 'invoice',
149
+ key: 'notes',
150
+ label: new LocalizedString([{ locale: 'en', value: 'Notes' }]),
151
+ description: null,
152
+ isRequired: false
153
+ }),
154
+ rules: {
155
+ type: CustomFieldType.NUMBER,
156
+ min: 1
157
+ }
158
+ };
159
+ expect(() => validateCustomFieldValue(definition, {
160
+ definitionUuid: definition.uuid,
161
+ type: CustomFieldType.TEXT,
162
+ value: 'hello'
163
+ })).toThrow(new CustomFieldValueValidationError('Custom field rules must match the definition type'));
164
+ });
165
+ });
166
+ //# sourceMappingURL=custom-field-value.validator.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-field-value.validator.unit.test.js","sourceRoot":"","sources":["../../lib/validators/custom-field-value.validator.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAA;AAErH,OAAO,EAAE,YAAY,EAA6B,MAAM,sCAAsC,CAAA;AAC9F,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;A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.0.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "imports": {
11
+ "#src/*": "./dist/*"
12
+ },
13
+ "exports": {
14
+ ".": "./dist/index.js"
15
+ },
16
+ "files": [
17
+ "dist/",
18
+ "skills/"
19
+ ],
20
+ "dependencies": {
21
+ "@wisemen/monetary": "^*",
22
+ "@wisemen/datewise": "^*",
23
+ "@wisemen/localized-string": "^*",
24
+ "@wisemen/api-error": "^*",
25
+ "@wisemen/validators": "^*",
26
+ "@wisemen/nestjs-typeorm": "^*"
27
+ },
28
+ "peerDependencies": {
29
+ "@nestjs/swagger": "^11.4.2",
30
+ "class-transformer": "^0.5.1",
31
+ "class-validator": "^0.15.1",
32
+ "@nestjs/common": "^11.1.19",
33
+ "@nestjs/core": "^11.1.19",
34
+ "@opentelemetry/api": "^1.9.1",
35
+ "typeorm": "^1.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "25.3.0",
39
+ "eslint": "10.2.1",
40
+ "oxlint": "1.59.0",
41
+ "oxlint-tsgolint": "0.20.0",
42
+ "typescript": "^5.9.3",
43
+ "expect": "30.4.1",
44
+ "@wisemen/eslint-config-nestjs": "1.1.1"
45
+ },
5
46
  "author": "Wisemen",
47
+ "license": "SEE LICENSE IN LICENSE.md",
6
48
  "repository": {
7
49
  "type": "git",
8
50
  "url": "https://github.com/wisemen-digital/wisemen-core",
9
51
  "directory": "packages/api/nestjs-custom-fields"
52
+ },
53
+ "scripts": {
54
+ "lint:oxlint": "oxlint --type-aware lib",
55
+ "lint:eslint": "eslint lib",
56
+ "lint": "pnpm run lint:oxlint && pnpm run lint:eslint",
57
+ "clean": "rm -rf ./dist",
58
+ "build": "tsc",
59
+ "pretest": "pnpm build",
60
+ "test": "node --test ./dist/**/*.test.js",
61
+ "prerelease": "npm run build",
62
+ "release": "pnpx release-it"
10
63
  }
11
- }
64
+ }
@@ -0,0 +1,263 @@
1
+ ---
2
+ name: nestjs-custom-fields
3
+ description: Use when working with the @wisemen/nestjs-custom-fields package — developer-defined custom fields in NestJS with TypeORM persistence and runtime validation. Covers registering the CustomFieldDefinition entity, authoring definitions with customFieldDefinition(), storing resolved values via @CustomFieldValueColumn(), exposing them through CustomFieldValueDto / @IsCustomFields(), and validating submissions with CustomFieldDefinitionsRepository + validateCustomFieldValues(). Use this whenever a task involves custom field definitions, CustomFieldValue columns, custom-field DTOs, or tenant-scoped field definitions, even if the package is not named explicitly.
4
+ ---
5
+
6
+ # @wisemen/nestjs-custom-fields - Getting Started
7
+
8
+ This package manages developer-defined custom field definitions and values. It
9
+ does not target end-user managed custom field creation, does not ship
10
+ migrations, and does not auto-discover definitions.
11
+
12
+ It is intended that custom field definitions are read-only for users.
13
+ Creating, updating, and deleting definitions is handled manually by developers
14
+ through migrations or `playground.ts` scripts.
15
+
16
+ Definition uniqueness is scoped by `entityType`. For non-tenant definitions,
17
+ `key` must be unique per `entityType`. For tenant-scoped definitions,
18
+ `key + tenantUuid` must be unique per `entityType`.
19
+
20
+ ## Step 1: Register The Exported Entity And Create The Table
21
+
22
+ This package already exports the effective `CustomFieldDefinition` TypeORM
23
+ entity. Add it to your datasource entities yourself so TypeORM knows about the
24
+ table metadata. After that, generate and run a migration so the table and the
25
+ exported entity's partial unique indexes are created in your database.
26
+
27
+ ```ts
28
+ import { DataSource } from 'typeorm'
29
+ import { CustomFieldDefinition } from '@wisemen/nestjs-custom-fields'
30
+
31
+ const datasource = new DataSource({
32
+ entities: ['dist/src/**/*.entity.js', CustomFieldDefinition]
33
+ })
34
+ ```
35
+
36
+ ## Step 2: Define Definitions And Insert Them In The Database
37
+
38
+ Create a definition with `customFieldDefinition(...)`, then insert it yourself.
39
+ The package does not discover definitions automatically. At the moment this is
40
+ mainly done through a migration or through `playground.ts`.
41
+
42
+ For persisted definitions, `tenantUuid` is part of the definition shape and
43
+ should be `null` for non-tenant definitions or a tenant UUID for tenant-scoped
44
+ definitions. This is different from repository lookups, where `tenantUuid` is
45
+ optional and can simply be omitted.
46
+
47
+ `key` uniqueness is enforced per `entityType`. Use a unique `key` for global
48
+ definitions, and a unique `key + tenantUuid` combination for tenant-specific
49
+ definitions.
50
+
51
+ It is recommended to define your `entityType` values in an enum instead of
52
+ repeating string literals across your application.
53
+
54
+ ```ts
55
+ import type { INestApplicationContext } from '@nestjs/common'
56
+ import { NestFactory } from '@nestjs/core'
57
+ import { JobContainer } from '@wisemen/app-container/fastify'
58
+ import { LocalizedString } from '@wisemen/localized-string'
59
+ import { DataSource } from 'typeorm'
60
+ import {
61
+ CustomFieldDefinition,
62
+ CustomFieldType,
63
+ customFieldDefinition
64
+ } from '@wisemen/nestjs-custom-fields'
65
+
66
+ enum CustomFieldEntityType {
67
+ TICKET = 'ticket'
68
+ }
69
+
70
+ export class Playground extends JobContainer {
71
+ async bootstrap(): Promise<INestApplicationContext> {
72
+ return await NestFactory.createApplicationContext(PlayGroundModule)
73
+ }
74
+
75
+ async execute(app: INestApplicationContext): Promise<void> {
76
+ const priorityField = customFieldDefinition(CustomFieldType.SINGLE_SELECT, {
77
+ tenantUuid: null,
78
+ entityType: CustomFieldEntityType.TICKET,
79
+ key: 'priority',
80
+ label: new LocalizedString([{ locale: 'en', value: 'Priority' }]),
81
+ description: null,
82
+ isRequired: true,
83
+ choices: [
84
+ {
85
+ value: 'low',
86
+ order: 1,
87
+ label: new LocalizedString([{ locale: 'en', value: 'Low' }])
88
+ },
89
+ {
90
+ value: 'high',
91
+ order: 2,
92
+ label: new LocalizedString([{ locale: 'en', value: 'High' }])
93
+ }
94
+ ]
95
+ })
96
+
97
+ await app.get(DataSource).manager.insert(CustomFieldDefinition, priorityField)
98
+ }
99
+ }
100
+ ```
101
+
102
+ ## Step 3: Store Values On The Entity With The Custom Column
103
+
104
+ Resolved custom field values live on your own entity. Use
105
+ `@CustomFieldValueColumn()` for the persisted values column.
106
+
107
+ ```ts
108
+ import { Entity, PrimaryGeneratedColumn } from 'typeorm'
109
+ import { CustomFieldValueColumn, type CustomFieldValue } from '@wisemen/nestjs-custom-fields'
110
+
111
+ @Entity()
112
+ export class Ticket {
113
+ @PrimaryGeneratedColumn('uuid')
114
+ uuid: string
115
+
116
+ @CustomFieldValueColumn({ nullable: true })
117
+ customFields: CustomFieldValue[] | null
118
+ }
119
+ ```
120
+
121
+ ## Step 4: Receive And Show Values With DTOs
122
+
123
+ Requests and responses use the DTO layer from this package. For incoming
124
+ payloads, use `CustomFieldValueDto` with `@IsCustomFields()`. For outgoing
125
+ payloads, map stored values back with `CustomFieldValueDto.from(...)`.
126
+
127
+ ```ts
128
+ // update-ticket.command.ts
129
+ import { ApiProperty } from '@nestjs/swagger'
130
+ import {
131
+ CustomFieldValueApiExtraModels,
132
+ CustomFieldValueDto,
133
+ CustomFieldValueDtoApiProperty,
134
+ IsCustomFields
135
+ } from '@wisemen/nestjs-custom-fields'
136
+
137
+ @CustomFieldValueApiExtraModels()
138
+ export class UpdateTicketCommand {
139
+ @CustomFieldValueDtoApiProperty({ isArray: true })
140
+ @IsCustomFields()
141
+ customFields: CustomFieldValueDto[]
142
+ }
143
+
144
+ // view-ticket.response.ts
145
+ @CustomFieldValueApiExtraModels()
146
+ export class ViewTicketResponse {
147
+ @ApiProperty({ type: String, format: 'uuid' })
148
+ uuid: string
149
+
150
+ @CustomFieldValueDtoApiProperty({ isArray: true })
151
+ customFields: CustomFieldValueDto[]
152
+
153
+ constructor(ticket: Ticket) {
154
+ this.uuid = ticket.uuid
155
+ this.customFields = ticket.customFields?.map((value) => CustomFieldValueDto.from(value)) ?? []
156
+ }
157
+ }
158
+ ```
159
+
160
+ Calling `parse()` on a DTO turns the transport-friendly input into the domain
161
+ custom field value shape, including richer value objects when needed. For
162
+ example, a `MonetaryDto` is parsed into the package's monetary value object
163
+ instead of staying a plain JSON structure.
164
+
165
+ ```ts
166
+ import {
167
+ CustomFieldType,
168
+ MonetaryCustomFieldValueDto
169
+ } from '@wisemen/nestjs-custom-fields'
170
+
171
+ const dto = new MonetaryCustomFieldValueDto()
172
+ dto.definitionUuid = definitionUuid
173
+ dto.value = {
174
+ amount: '12.50',
175
+ currency: 'EUR',
176
+ precision: 2
177
+ }
178
+
179
+ const parsed = dto.parse()
180
+
181
+ // parsed is now a domain custom field value object:
182
+ // {
183
+ // definitionUuid,
184
+ // type: CustomFieldType.MONETARY,
185
+ // value: dto.value.parse()
186
+ // }
187
+ ```
188
+
189
+ ## Step 5: Retrieve Definitions For Validation
190
+
191
+ When you process submitted values, retrieve the matching definitions through
192
+ `CustomFieldDefinitionsRepository` and validate against them with
193
+ `validateCustomFieldValues(...)`. If you also want to return definitions from
194
+ an API, map the same repository results with `CustomFieldDefinitionResponse`.
195
+ To inject the repository, register `CustomFieldDefinitionRepositoryModule` in
196
+ the Nest module that owns your use case or controller.
197
+
198
+ ```ts
199
+ import { Module } from '@nestjs/common'
200
+ import { CustomFieldDefinitionRepositoryModule } from '@wisemen/nestjs-custom-fields'
201
+
202
+ @Module({
203
+ imports: [CustomFieldDefinitionRepositoryModule],
204
+ providers: [UpdateTicketUseCase]
205
+ })
206
+ export class UpdateTicketModule {}
207
+ ```
208
+
209
+ `validateCustomFieldValues(...)` throws `CustomFieldValueValidationError` when
210
+ the submitted values do not match the definitions. In controllers, document
211
+ that error according to the `@wisemen/api-error` package pattern by registering
212
+ it with `@ApiErrorResponse(...)`.
213
+
214
+ ```ts
215
+ import { ApiErrorResponse } from '@wisemen/api-error'
216
+ import { CustomFieldValueValidationError } from '@wisemen/nestjs-custom-fields'
217
+
218
+ @ApiErrorResponse(CustomFieldValueValidationError)
219
+ async update(...): Promise<void> {
220
+ // controller logic
221
+ }
222
+ ```
223
+ On repository lookups, `tenantUuid` is optional. Omit it to work with
224
+ non-tenant definitions, or set it to retrieve tenant-specific definitions in a
225
+ multi-tenant setup.
226
+
227
+ After DTO parsing, validate the resolved values against the definitions that
228
+ apply for that entity and tenant. This is the runtime check that enforces the
229
+ definition rules.
230
+
231
+ The runtime order matters: call `.parse()` on the DTOs first, then run
232
+ `validateCustomFieldValues(...)` against the definitions for that
233
+ `entityType` and tenant scope.
234
+
235
+ ```ts
236
+ import { Injectable } from '@nestjs/common'
237
+ import {
238
+ CustomFieldDefinitionResponse,
239
+ CustomFieldDefinitionsRepository,
240
+ validateCustomFieldValues
241
+ } from '@wisemen/nestjs-custom-fields'
242
+
243
+ enum CustomFieldEntityType {
244
+ TICKET = 'ticket'
245
+ }
246
+
247
+ @Injectable()
248
+ export class UpdateTicketUseCase {
249
+ constructor(
250
+ private readonly repository: CustomFieldDefinitionsRepository
251
+ ) {}
252
+
253
+ async execute(command: UpdateTicketCommand): Promise<void> {
254
+ const values = command.customFields.map((value) => value.parse())
255
+ const definitions = await this.repository.findDefinitions({
256
+ entityType: CustomFieldEntityType.TICKET
257
+ })
258
+ validateCustomFieldValues(definitions, values)
259
+
260
+ // Remaining use-case logic
261
+ }
262
+ }
263
+ ```