@decaf-ts/decorator-validation 1.11.24 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/lib/cjs/constants/errors.js.map +1 -0
  2. package/lib/cjs/constants/index.js.map +1 -0
  3. package/lib/cjs/constants/validation.js.map +1 -0
  4. package/lib/{index.cjs → cjs/index.cjs} +1 -1
  5. package/lib/cjs/index.js.map +1 -0
  6. package/lib/cjs/model/Builder.js.map +1 -0
  7. package/lib/cjs/model/Model.js.map +1 -0
  8. package/lib/cjs/model/ModelErrorDefinition.js.map +1 -0
  9. package/lib/cjs/model/ModelRegistry.js.map +1 -0
  10. package/lib/cjs/model/constants.js.map +1 -0
  11. package/lib/cjs/model/construction.js.map +1 -0
  12. package/lib/cjs/model/decorators.js.map +1 -0
  13. package/lib/cjs/model/index.js.map +1 -0
  14. package/lib/{model → cjs/model}/types.js.map +1 -1
  15. package/lib/cjs/model/utils.js.map +1 -0
  16. package/lib/cjs/model/validation.js.map +1 -0
  17. package/lib/cjs/overrides/Metadata.js.map +1 -0
  18. package/lib/cjs/overrides/index.js.map +1 -0
  19. package/lib/cjs/overrides/overrides.js.map +1 -0
  20. package/lib/{overrides → cjs/overrides}/types.js.map +1 -1
  21. package/lib/cjs/types/index.js.map +1 -0
  22. package/lib/{types → cjs/types}/validation.js.map +1 -1
  23. package/lib/cjs/utils/DateBuilder.js.map +1 -0
  24. package/lib/cjs/utils/PathProxy.js.map +1 -0
  25. package/lib/cjs/utils/constants.js.map +1 -0
  26. package/lib/cjs/utils/dates.js.map +1 -0
  27. package/lib/cjs/utils/equality.js.map +1 -0
  28. package/lib/cjs/utils/hashing.js.map +1 -0
  29. package/lib/cjs/utils/index.js.map +1 -0
  30. package/lib/{utils → cjs/utils}/registry.js.map +1 -1
  31. package/lib/cjs/utils/serialization.js.map +1 -0
  32. package/lib/cjs/utils/serializers.js.map +1 -0
  33. package/lib/cjs/utils/strings.js.map +1 -0
  34. package/lib/{utils → cjs/utils}/types.js.map +1 -1
  35. package/lib/cjs/validation/Validation.js.map +1 -0
  36. package/lib/cjs/validation/Validators/AsyncValidator.js.map +1 -0
  37. package/lib/cjs/validation/Validators/BaseValidator.js.map +1 -0
  38. package/lib/cjs/validation/Validators/DateValidator.js.map +1 -0
  39. package/lib/cjs/validation/Validators/DiffValidator.js.map +1 -0
  40. package/lib/cjs/validation/Validators/EmailValidator.js.map +1 -0
  41. package/lib/cjs/validation/Validators/EqualsValidator.js.map +1 -0
  42. package/lib/cjs/validation/Validators/GreaterThanOrEqualValidator.js.map +1 -0
  43. package/lib/cjs/validation/Validators/GreaterThanValidator.js.map +1 -0
  44. package/lib/cjs/validation/Validators/LessThanOrEqualValidator.js.map +1 -0
  45. package/lib/cjs/validation/Validators/LessThanValidator.js.map +1 -0
  46. package/lib/cjs/validation/Validators/ListValidator.js.map +1 -0
  47. package/lib/cjs/validation/Validators/MaxLengthValidator.js.map +1 -0
  48. package/lib/cjs/validation/Validators/MaxValidator.js.map +1 -0
  49. package/lib/cjs/validation/Validators/MinLengthValidator.js.map +1 -0
  50. package/lib/cjs/validation/Validators/MinValidator.js.map +1 -0
  51. package/lib/cjs/validation/Validators/OptionValidator.js.map +1 -0
  52. package/lib/cjs/validation/Validators/PasswordValidator.js.map +1 -0
  53. package/lib/cjs/validation/Validators/PatternValidator.js.map +1 -0
  54. package/lib/cjs/validation/Validators/RequiredValidator.js.map +1 -0
  55. package/lib/cjs/validation/Validators/StepValidator.js.map +1 -0
  56. package/lib/cjs/validation/Validators/TypeValidator.js.map +1 -0
  57. package/lib/cjs/validation/Validators/URLValidator.js.map +1 -0
  58. package/lib/cjs/validation/Validators/Validator.js.map +1 -0
  59. package/lib/cjs/validation/Validators/ValidatorRegistry.js.map +1 -0
  60. package/lib/cjs/validation/Validators/constants.js.map +1 -0
  61. package/lib/cjs/validation/Validators/decorators.js.map +1 -0
  62. package/lib/cjs/validation/Validators/index.js.map +1 -0
  63. package/lib/cjs/validation/Validators/utils.js.map +1 -0
  64. package/lib/cjs/validation/decorators.js.map +1 -0
  65. package/lib/cjs/validation/index.js.map +1 -0
  66. package/lib/cjs/validation/types.js.map +1 -0
  67. package/lib/esm/index.js +1 -1
  68. package/lib/types/index.d.ts +19 -0
  69. package/package.json +12 -5
  70. package/lib/constants/errors.js.map +0 -1
  71. package/lib/constants/index.js.map +0 -1
  72. package/lib/constants/validation.js.map +0 -1
  73. package/lib/esm/constants/errors.d.ts +0 -17
  74. package/lib/esm/constants/index.d.ts +0 -2
  75. package/lib/esm/constants/validation.d.ts +0 -16
  76. package/lib/esm/index.d.ts +0 -20
  77. package/lib/index.d.ts +0 -20
  78. package/lib/index.js.map +0 -1
  79. package/lib/model/Builder.d.ts +0 -86
  80. package/lib/model/Builder.js.map +0 -1
  81. package/lib/model/Model.d.ts +0 -286
  82. package/lib/model/Model.js.map +0 -1
  83. package/lib/model/ModelErrorDefinition.d.ts +0 -22
  84. package/lib/model/ModelErrorDefinition.js.map +0 -1
  85. package/lib/model/ModelRegistry.d.ts +0 -181
  86. package/lib/model/ModelRegistry.js.map +0 -1
  87. package/lib/model/constants.d.ts +0 -65
  88. package/lib/model/constants.js.map +0 -1
  89. package/lib/model/construction.d.ts +0 -46
  90. package/lib/model/construction.js.map +0 -1
  91. package/lib/model/decorators.d.ts +0 -47
  92. package/lib/model/decorators.js.map +0 -1
  93. package/lib/model/index.d.ts +0 -10
  94. package/lib/model/index.js.map +0 -1
  95. package/lib/model/types.d.ts +0 -145
  96. package/lib/model/utils.d.ts +0 -13
  97. package/lib/model/utils.js.map +0 -1
  98. package/lib/model/validation.d.ts +0 -92
  99. package/lib/model/validation.js.map +0 -1
  100. package/lib/overrides/Metadata.d.ts +0 -132
  101. package/lib/overrides/Metadata.js.map +0 -1
  102. package/lib/overrides/index.d.ts +0 -3
  103. package/lib/overrides/index.js.map +0 -1
  104. package/lib/overrides/overrides.d.ts +0 -1
  105. package/lib/overrides/overrides.js.map +0 -1
  106. package/lib/overrides/types.d.ts +0 -17
  107. package/lib/types/index.js.map +0 -1
  108. package/lib/types/validation.d.ts +0 -28
  109. package/lib/utils/DateBuilder.d.ts +0 -121
  110. package/lib/utils/DateBuilder.js.map +0 -1
  111. package/lib/utils/PathProxy.d.ts +0 -43
  112. package/lib/utils/PathProxy.js.map +0 -1
  113. package/lib/utils/constants.d.ts +0 -32
  114. package/lib/utils/constants.js.map +0 -1
  115. package/lib/utils/dates.d.ts +0 -86
  116. package/lib/utils/dates.js.map +0 -1
  117. package/lib/utils/equality.d.ts +0 -56
  118. package/lib/utils/equality.js.map +0 -1
  119. package/lib/utils/hashing.d.ts +0 -82
  120. package/lib/utils/hashing.js.map +0 -1
  121. package/lib/utils/index.d.ts +0 -11
  122. package/lib/utils/index.js.map +0 -1
  123. package/lib/utils/registry.d.ts +0 -68
  124. package/lib/utils/serialization.d.ts +0 -12
  125. package/lib/utils/serialization.js.map +0 -1
  126. package/lib/utils/serializers.d.ts +0 -41
  127. package/lib/utils/serializers.js.map +0 -1
  128. package/lib/utils/strings.d.ts +0 -25
  129. package/lib/utils/strings.js.map +0 -1
  130. package/lib/utils/types.d.ts +0 -35
  131. package/lib/validation/Validation.d.ts +0 -53
  132. package/lib/validation/Validation.js.map +0 -1
  133. package/lib/validation/Validators/AsyncValidator.d.ts +0 -72
  134. package/lib/validation/Validators/AsyncValidator.js.map +0 -1
  135. package/lib/validation/Validators/BaseValidator.d.ts +0 -118
  136. package/lib/validation/Validators/BaseValidator.js.map +0 -1
  137. package/lib/validation/Validators/DateValidator.d.ts +0 -60
  138. package/lib/validation/Validators/DateValidator.js.map +0 -1
  139. package/lib/validation/Validators/DiffValidator.d.ts +0 -29
  140. package/lib/validation/Validators/DiffValidator.js.map +0 -1
  141. package/lib/validation/Validators/EmailValidator.d.ts +0 -60
  142. package/lib/validation/Validators/EmailValidator.js.map +0 -1
  143. package/lib/validation/Validators/EqualsValidator.d.ts +0 -29
  144. package/lib/validation/Validators/EqualsValidator.js.map +0 -1
  145. package/lib/validation/Validators/GreaterThanOrEqualValidator.d.ts +0 -29
  146. package/lib/validation/Validators/GreaterThanOrEqualValidator.js.map +0 -1
  147. package/lib/validation/Validators/GreaterThanValidator.d.ts +0 -29
  148. package/lib/validation/Validators/GreaterThanValidator.js.map +0 -1
  149. package/lib/validation/Validators/LessThanOrEqualValidator.d.ts +0 -29
  150. package/lib/validation/Validators/LessThanOrEqualValidator.js.map +0 -1
  151. package/lib/validation/Validators/LessThanValidator.d.ts +0 -29
  152. package/lib/validation/Validators/LessThanValidator.js.map +0 -1
  153. package/lib/validation/Validators/ListValidator.d.ts +0 -66
  154. package/lib/validation/Validators/ListValidator.js.map +0 -1
  155. package/lib/validation/Validators/MaxLengthValidator.d.ts +0 -29
  156. package/lib/validation/Validators/MaxLengthValidator.js.map +0 -1
  157. package/lib/validation/Validators/MaxValidator.d.ts +0 -74
  158. package/lib/validation/Validators/MaxValidator.js.map +0 -1
  159. package/lib/validation/Validators/MinLengthValidator.d.ts +0 -29
  160. package/lib/validation/Validators/MinLengthValidator.js.map +0 -1
  161. package/lib/validation/Validators/MinValidator.d.ts +0 -74
  162. package/lib/validation/Validators/MinValidator.js.map +0 -1
  163. package/lib/validation/Validators/OptionValidator.d.ts +0 -29
  164. package/lib/validation/Validators/OptionValidator.js.map +0 -1
  165. package/lib/validation/Validators/PasswordValidator.d.ts +0 -28
  166. package/lib/validation/Validators/PasswordValidator.js.map +0 -1
  167. package/lib/validation/Validators/PatternValidator.d.ts +0 -103
  168. package/lib/validation/Validators/PatternValidator.js.map +0 -1
  169. package/lib/validation/Validators/RequiredValidator.d.ts +0 -74
  170. package/lib/validation/Validators/RequiredValidator.js.map +0 -1
  171. package/lib/validation/Validators/StepValidator.d.ts +0 -29
  172. package/lib/validation/Validators/StepValidator.js.map +0 -1
  173. package/lib/validation/Validators/TypeValidator.d.ts +0 -79
  174. package/lib/validation/Validators/TypeValidator.js.map +0 -1
  175. package/lib/validation/Validators/URLValidator.d.ts +0 -61
  176. package/lib/validation/Validators/URLValidator.js.map +0 -1
  177. package/lib/validation/Validators/Validator.d.ts +0 -65
  178. package/lib/validation/Validators/Validator.js.map +0 -1
  179. package/lib/validation/Validators/ValidatorRegistry.d.ts +0 -41
  180. package/lib/validation/Validators/ValidatorRegistry.js.map +0 -1
  181. package/lib/validation/Validators/constants.d.ts +0 -157
  182. package/lib/validation/Validators/constants.js.map +0 -1
  183. package/lib/validation/Validators/decorators.d.ts +0 -12
  184. package/lib/validation/Validators/decorators.js.map +0 -1
  185. package/lib/validation/Validators/index.d.ts +0 -26
  186. package/lib/validation/Validators/index.js.map +0 -1
  187. package/lib/validation/Validators/utils.d.ts +0 -75
  188. package/lib/validation/Validators/utils.js.map +0 -1
  189. package/lib/validation/decorators.d.ts +0 -313
  190. package/lib/validation/decorators.js.map +0 -1
  191. package/lib/validation/index.d.ts +0 -9
  192. package/lib/validation/index.js.map +0 -1
  193. package/lib/validation/types.d.ts +0 -309
  194. package/lib/validation/types.js.map +0 -1
  195. /package/lib/{constants → cjs/constants}/errors.cjs +0 -0
  196. /package/lib/{constants → cjs/constants}/index.cjs +0 -0
  197. /package/lib/{constants → cjs/constants}/validation.cjs +0 -0
  198. /package/lib/{model → cjs/model}/Builder.cjs +0 -0
  199. /package/lib/{model → cjs/model}/Model.cjs +0 -0
  200. /package/lib/{model → cjs/model}/ModelErrorDefinition.cjs +0 -0
  201. /package/lib/{model → cjs/model}/ModelRegistry.cjs +0 -0
  202. /package/lib/{model → cjs/model}/constants.cjs +0 -0
  203. /package/lib/{model → cjs/model}/construction.cjs +0 -0
  204. /package/lib/{model → cjs/model}/decorators.cjs +0 -0
  205. /package/lib/{model → cjs/model}/index.cjs +0 -0
  206. /package/lib/{model → cjs/model}/types.cjs +0 -0
  207. /package/lib/{model → cjs/model}/utils.cjs +0 -0
  208. /package/lib/{model → cjs/model}/validation.cjs +0 -0
  209. /package/lib/{overrides → cjs/overrides}/Metadata.cjs +0 -0
  210. /package/lib/{overrides → cjs/overrides}/index.cjs +0 -0
  211. /package/lib/{overrides → cjs/overrides}/overrides.cjs +0 -0
  212. /package/lib/{overrides → cjs/overrides}/types.cjs +0 -0
  213. /package/lib/{types → cjs/types}/index.cjs +0 -0
  214. /package/lib/{types → cjs/types}/validation.cjs +0 -0
  215. /package/lib/{utils → cjs/utils}/DateBuilder.cjs +0 -0
  216. /package/lib/{utils → cjs/utils}/PathProxy.cjs +0 -0
  217. /package/lib/{utils → cjs/utils}/constants.cjs +0 -0
  218. /package/lib/{utils → cjs/utils}/dates.cjs +0 -0
  219. /package/lib/{utils → cjs/utils}/equality.cjs +0 -0
  220. /package/lib/{utils → cjs/utils}/hashing.cjs +0 -0
  221. /package/lib/{utils → cjs/utils}/index.cjs +0 -0
  222. /package/lib/{utils → cjs/utils}/registry.cjs +0 -0
  223. /package/lib/{utils → cjs/utils}/serialization.cjs +0 -0
  224. /package/lib/{utils → cjs/utils}/serializers.cjs +0 -0
  225. /package/lib/{utils → cjs/utils}/strings.cjs +0 -0
  226. /package/lib/{utils → cjs/utils}/types.cjs +0 -0
  227. /package/lib/{validation → cjs/validation}/Validation.cjs +0 -0
  228. /package/lib/{validation → cjs/validation}/Validators/AsyncValidator.cjs +0 -0
  229. /package/lib/{validation → cjs/validation}/Validators/BaseValidator.cjs +0 -0
  230. /package/lib/{validation → cjs/validation}/Validators/DateValidator.cjs +0 -0
  231. /package/lib/{validation → cjs/validation}/Validators/DiffValidator.cjs +0 -0
  232. /package/lib/{validation → cjs/validation}/Validators/EmailValidator.cjs +0 -0
  233. /package/lib/{validation → cjs/validation}/Validators/EqualsValidator.cjs +0 -0
  234. /package/lib/{validation → cjs/validation}/Validators/GreaterThanOrEqualValidator.cjs +0 -0
  235. /package/lib/{validation → cjs/validation}/Validators/GreaterThanValidator.cjs +0 -0
  236. /package/lib/{validation → cjs/validation}/Validators/LessThanOrEqualValidator.cjs +0 -0
  237. /package/lib/{validation → cjs/validation}/Validators/LessThanValidator.cjs +0 -0
  238. /package/lib/{validation → cjs/validation}/Validators/ListValidator.cjs +0 -0
  239. /package/lib/{validation → cjs/validation}/Validators/MaxLengthValidator.cjs +0 -0
  240. /package/lib/{validation → cjs/validation}/Validators/MaxValidator.cjs +0 -0
  241. /package/lib/{validation → cjs/validation}/Validators/MinLengthValidator.cjs +0 -0
  242. /package/lib/{validation → cjs/validation}/Validators/MinValidator.cjs +0 -0
  243. /package/lib/{validation → cjs/validation}/Validators/OptionValidator.cjs +0 -0
  244. /package/lib/{validation → cjs/validation}/Validators/PasswordValidator.cjs +0 -0
  245. /package/lib/{validation → cjs/validation}/Validators/PatternValidator.cjs +0 -0
  246. /package/lib/{validation → cjs/validation}/Validators/RequiredValidator.cjs +0 -0
  247. /package/lib/{validation → cjs/validation}/Validators/StepValidator.cjs +0 -0
  248. /package/lib/{validation → cjs/validation}/Validators/TypeValidator.cjs +0 -0
  249. /package/lib/{validation → cjs/validation}/Validators/URLValidator.cjs +0 -0
  250. /package/lib/{validation → cjs/validation}/Validators/Validator.cjs +0 -0
  251. /package/lib/{validation → cjs/validation}/Validators/ValidatorRegistry.cjs +0 -0
  252. /package/lib/{validation → cjs/validation}/Validators/constants.cjs +0 -0
  253. /package/lib/{validation → cjs/validation}/Validators/decorators.cjs +0 -0
  254. /package/lib/{validation → cjs/validation}/Validators/index.cjs +0 -0
  255. /package/lib/{validation → cjs/validation}/Validators/utils.cjs +0 -0
  256. /package/lib/{validation → cjs/validation}/decorators.cjs +0 -0
  257. /package/lib/{validation → cjs/validation}/index.cjs +0 -0
  258. /package/lib/{validation → cjs/validation}/types.cjs +0 -0
  259. /package/lib/{constants → types/constants}/errors.d.ts +0 -0
  260. /package/lib/{constants → types/constants}/index.d.ts +0 -0
  261. /package/lib/{constants → types/constants}/validation.d.ts +0 -0
  262. /package/lib/{esm → types}/model/Builder.d.ts +0 -0
  263. /package/lib/{esm → types}/model/Model.d.ts +0 -0
  264. /package/lib/{esm → types}/model/ModelErrorDefinition.d.ts +0 -0
  265. /package/lib/{esm → types}/model/ModelRegistry.d.ts +0 -0
  266. /package/lib/{esm → types}/model/constants.d.ts +0 -0
  267. /package/lib/{esm → types}/model/construction.d.ts +0 -0
  268. /package/lib/{esm → types}/model/decorators.d.ts +0 -0
  269. /package/lib/{esm → types}/model/index.d.ts +0 -0
  270. /package/lib/{esm → types}/model/types.d.ts +0 -0
  271. /package/lib/{esm → types}/model/utils.d.ts +0 -0
  272. /package/lib/{esm → types}/model/validation.d.ts +0 -0
  273. /package/lib/{esm → types}/overrides/Metadata.d.ts +0 -0
  274. /package/lib/{esm → types}/overrides/index.d.ts +0 -0
  275. /package/lib/{esm → types}/overrides/overrides.d.ts +0 -0
  276. /package/lib/{esm → types}/overrides/types.d.ts +0 -0
  277. /package/lib/{esm → types}/types/index.d.ts +0 -0
  278. /package/lib/{esm → types}/types/validation.d.ts +0 -0
  279. /package/lib/{esm → types}/utils/DateBuilder.d.ts +0 -0
  280. /package/lib/{esm → types}/utils/PathProxy.d.ts +0 -0
  281. /package/lib/{esm → types}/utils/constants.d.ts +0 -0
  282. /package/lib/{esm → types}/utils/dates.d.ts +0 -0
  283. /package/lib/{esm → types}/utils/equality.d.ts +0 -0
  284. /package/lib/{esm → types}/utils/hashing.d.ts +0 -0
  285. /package/lib/{esm → types}/utils/index.d.ts +0 -0
  286. /package/lib/{esm → types}/utils/registry.d.ts +0 -0
  287. /package/lib/{esm → types}/utils/serialization.d.ts +0 -0
  288. /package/lib/{esm → types}/utils/serializers.d.ts +0 -0
  289. /package/lib/{esm → types}/utils/strings.d.ts +0 -0
  290. /package/lib/{esm → types}/utils/types.d.ts +0 -0
  291. /package/lib/{esm → types}/validation/Validation.d.ts +0 -0
  292. /package/lib/{esm → types}/validation/Validators/AsyncValidator.d.ts +0 -0
  293. /package/lib/{esm → types}/validation/Validators/BaseValidator.d.ts +0 -0
  294. /package/lib/{esm → types}/validation/Validators/DateValidator.d.ts +0 -0
  295. /package/lib/{esm → types}/validation/Validators/DiffValidator.d.ts +0 -0
  296. /package/lib/{esm → types}/validation/Validators/EmailValidator.d.ts +0 -0
  297. /package/lib/{esm → types}/validation/Validators/EqualsValidator.d.ts +0 -0
  298. /package/lib/{esm → types}/validation/Validators/GreaterThanOrEqualValidator.d.ts +0 -0
  299. /package/lib/{esm → types}/validation/Validators/GreaterThanValidator.d.ts +0 -0
  300. /package/lib/{esm → types}/validation/Validators/LessThanOrEqualValidator.d.ts +0 -0
  301. /package/lib/{esm → types}/validation/Validators/LessThanValidator.d.ts +0 -0
  302. /package/lib/{esm → types}/validation/Validators/ListValidator.d.ts +0 -0
  303. /package/lib/{esm → types}/validation/Validators/MaxLengthValidator.d.ts +0 -0
  304. /package/lib/{esm → types}/validation/Validators/MaxValidator.d.ts +0 -0
  305. /package/lib/{esm → types}/validation/Validators/MinLengthValidator.d.ts +0 -0
  306. /package/lib/{esm → types}/validation/Validators/MinValidator.d.ts +0 -0
  307. /package/lib/{esm → types}/validation/Validators/OptionValidator.d.ts +0 -0
  308. /package/lib/{esm → types}/validation/Validators/PasswordValidator.d.ts +0 -0
  309. /package/lib/{esm → types}/validation/Validators/PatternValidator.d.ts +0 -0
  310. /package/lib/{esm → types}/validation/Validators/RequiredValidator.d.ts +0 -0
  311. /package/lib/{esm → types}/validation/Validators/StepValidator.d.ts +0 -0
  312. /package/lib/{esm → types}/validation/Validators/TypeValidator.d.ts +0 -0
  313. /package/lib/{esm → types}/validation/Validators/URLValidator.d.ts +0 -0
  314. /package/lib/{esm → types}/validation/Validators/Validator.d.ts +0 -0
  315. /package/lib/{esm → types}/validation/Validators/ValidatorRegistry.d.ts +0 -0
  316. /package/lib/{esm → types}/validation/Validators/constants.d.ts +0 -0
  317. /package/lib/{esm → types}/validation/Validators/decorators.d.ts +0 -0
  318. /package/lib/{esm → types}/validation/Validators/index.d.ts +0 -0
  319. /package/lib/{esm → types}/validation/Validators/utils.d.ts +0 -0
  320. /package/lib/{esm → types}/validation/decorators.d.ts +0 -0
  321. /package/lib/{esm → types}/validation/index.d.ts +0 -0
  322. /package/lib/{esm → types}/validation/types.d.ts +0 -0
@@ -1,181 +0,0 @@
1
- import { Constructor } from "@decaf-ts/decoration";
2
- import { ModelBuilderFunction, ModelConstructor } from "./types";
3
- import { type Model } from "./Model";
4
- import { BuilderRegistry } from "../utils/registry";
5
- /**
6
- * @description Registry type for storing and retrieving model constructors
7
- * @summary The ModelRegistry type defines a registry for model constructors that extends
8
- * the BuilderRegistry interface. It provides a standardized way to register, retrieve,
9
- * and build model instances, enabling the model system to work with different types of models.
10
- *
11
- * @interface ModelRegistry
12
- * @template T Type of model that can be registered, must extend Model
13
- * @extends BuilderRegistry<T>
14
- * @memberOf module:decorator-validation
15
- * @category Model
16
- */
17
- export type ModelRegistry<T extends Model> = BuilderRegistry<T>;
18
- /**
19
- * @description Registry manager for model constructors that enables serialization and rebuilding
20
- * @summary The ModelRegistryManager implements the ModelRegistry interface and provides
21
- * functionality for registering, retrieving, and building model instances. It maintains
22
- * a cache of model constructors indexed by name, allowing for efficient lookup and instantiation.
23
- * This class is essential for the serialization and deserialization of model objects.
24
- *
25
- * @param {function(Record<string, any>): boolean} [testFunction] - Function to test if an object is a model, defaults to {@link Model#isModel}
26
- *
27
- * @class ModelRegistryManager
28
- * @template M Type of model that can be registered, must extend Model
29
- * @implements ModelRegistry<M>
30
- * @category Model
31
- *
32
- * @example
33
- * ```typescript
34
- * // Create a model registry
35
- * const registry = new ModelRegistryManager();
36
- *
37
- * // Register a model class
38
- * registry.register(User);
39
- *
40
- * // Retrieve a model constructor by name
41
- * const UserClass = registry.get("User");
42
- *
43
- * // Build a model instance from a plain object
44
- * const userData = { name: "John", age: 30 };
45
- * const user = registry.build(userData, "User");
46
- * ```
47
- *
48
- * @mermaid
49
- * sequenceDiagram
50
- * participant C as Client
51
- * participant R as ModelRegistryManager
52
- * participant M as Model Class
53
- *
54
- * C->>R: new ModelRegistryManager(testFunction)
55
- * C->>R: register(ModelClass)
56
- * R->>R: Store in cache
57
- * C->>R: get("ModelName")
58
- * R-->>C: ModelClass constructor
59
- * C->>R: build(data, "ModelName")
60
- * R->>R: Get constructor from cache
61
- * R->>M: new ModelClass(data)
62
- * M-->>R: Model instance
63
- * R-->>C: Model instance
64
- */
65
- export declare class ModelRegistryManager<M extends Model<true | false>> implements ModelRegistry<M> {
66
- private cache;
67
- private readonly testFunction;
68
- constructor(testFunction?: (obj: Record<string, any>) => boolean);
69
- /**
70
- * @description Registers a model constructor with the registry
71
- * @summary Adds a model constructor to the registry cache, making it available for
72
- * later retrieval and instantiation. If no name is provided, the constructor's name
73
- * property is used as the key in the registry.
74
- *
75
- * @param {ModelConstructor<M>} constructor - The model constructor to register
76
- * @param {string} [name] - Optional name to register the constructor under, defaults to constructor.name
77
- * @return {void}
78
- * @throws {Error} If the constructor is not a function
79
- */
80
- register(constructor: ModelConstructor<M>, name?: string): void;
81
- /**
82
- * @summary Gets a registered Model {@link ModelConstructor}
83
- * @param {string} name
84
- */
85
- get(name: string): ModelConstructor<M> | undefined;
86
- /**
87
- * @param {Record<string, any>} obj
88
- * @param {string} [clazz] when provided, it will attempt to find the matching constructor
89
- *
90
- * @throws Error If clazz is not found, or obj is not a {@link Model} meaning it has no {@link ModelKeys.ANCHOR} property
91
- */
92
- build(obj?: Record<string, any>, clazz?: string): M;
93
- /**
94
- * @description Configures the global model builder function
95
- * @summary Sets the Global {@link ModelBuilderFunction} used for building model instances
96
- *
97
- * @param {ModelBuilderFunction} [builder] - The builder function to set as the global builder
98
- * @return {void}
99
- */
100
- static setBuilder(builder?: ModelBuilderFunction): void;
101
- /**
102
- * @description Retrieves the currently configured global model builder function
103
- * @summary Returns the current global {@link ModelBuilderFunction} used for building model instances
104
- *
105
- * @return {ModelBuilderFunction | undefined} - The current global builder function or undefined if not set
106
- */
107
- static getBuilder(): ModelBuilderFunction | undefined;
108
- /**
109
- * @description Copies and rebuilds properties from a source object to a model instance, handling nested models
110
- * @summary Repopulates the instance with properties from the new Model Object, recursively rebuilding nested models
111
- *
112
- * @template T
113
- * @param {T} self - The target model instance to update
114
- * @param {T | Record<string, any>} [obj] - The source object containing properties to copy
115
- * @return {T} - The updated model instance with rebuilt nested models
116
- *
117
- * @mermaid
118
- * sequenceDiagram
119
- * participant C as Client
120
- * participant M as Model.fromModel
121
- * participant B as Model.build
122
- * participant R as Reflection
123
- *
124
- * C->>M: fromModel(self, obj)
125
- * M->>M: Get attributes from self
126
- * loop For each property
127
- * M->>M: Copy property from obj to self
128
- * alt Property is a model
129
- * M->>M: Check if property is a model
130
- * M->>B: build(property, modelType)
131
- * B-->>M: Return built model
132
- * else Property is a complex type
133
- * M->>R: Get property decorators
134
- * R-->>M: Return decorators
135
- * M->>M: Filter type decorators
136
- * alt Property is Array/Set with list decorator
137
- * M->>M: Process each item in collection
138
- * loop For each item
139
- * M->>B: build(item, itemModelType)
140
- * B-->>M: Return built model
141
- * end
142
- * else Property is another model type
143
- * M->>B: build(property, propertyType)
144
- * B-->>M: Return built model
145
- * end
146
- * end
147
- * end
148
- * M-->>C: Return updated self
149
- */
150
- static fromModel<T extends Model>(self: T, obj?: T | Record<string, any>): T;
151
- /**
152
- * @description Provides access to the current model registry
153
- * @summary Returns the current {@link ModelRegistryManager} instance, creating one if it doesn't exist
154
- *
155
- * @return {ModelRegistry<any>} - The current model registry, defaults to a new {@link ModelRegistryManager} if not set
156
- * @private
157
- */
158
- static getRegistry(): BuilderRegistry<any>;
159
- /**
160
- * @description Configures the model registry to be used by the Model system
161
- * @summary Sets the current model registry to a custom implementation
162
- *
163
- * @param {BuilderRegistry<any>} modelRegistry - The new implementation of Registry to use
164
- * @return {void}
165
- */
166
- static setRegistry(modelRegistry: BuilderRegistry<any>): void;
167
- }
168
- /**
169
- * @summary Bulk Registers Models
170
- * @description Useful when using bundlers that might not evaluate all the code at once
171
- *
172
- * @template M extends Model
173
- * @param {Array<Constructor<M>> | Array<{name: string, constructor: Constructor<M>}>} [models]
174
- *
175
- * @memberOf module:decorator-validation
176
- * @category Model
177
- */
178
- export declare function bulkModelRegister<M extends Model>(...models: (Constructor<M> | {
179
- name: string;
180
- constructor: Constructor<M>;
181
- })[]): void;
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModelRegistry.js","sourceRoot":"","sources":["../../src/model/ModelRegistry.ts"],"names":[],"mappings":";;;AAoWA,8CAcC;AAlXD,qDAA6D;AAK7D,+CAAsD;AACtD,qDAA2E;AAE3E,IAAI,oBAAsD,CAAC;AAC3D,IAAI,mBAAyC,CAAC;AAgB9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAa,oBAAoB;IAM/B,YACE,eAAsD,qBAAQ,CAAC,OAAO;QAJhE,UAAK,GAAwC,EAAE,CAAC;QAMtD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,WAAgC,EAAE,IAAa;QACtD,IAAI,OAAO,WAAW,KAAK,UAAU;YACnC,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;QACJ,IAAI,GAAG,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,IAAY;QACd,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxB,6DAA6D;QAC/D,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAA2B,EAAE,EAAE,KAAc;QACjD,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,KAAK,IAAI,qBAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,WAAkB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AC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAChB,CAAC;QACpB,oBAAoB,CAAC,WAAW,EAAE,CAAC,QAAQ,CACzC,WAAW,EACV,CAAoB,CAAC,IAAI,CAC3B,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,65 +0,0 @@
1
- /**
2
- * @description Enumeration of JavaScript primitive type identifiers used by the model system.
3
- * @summary References the relevant JS primitives and standardizes their string representations across the library.
4
- * @property {string} STRING references the string primitive
5
- * @property {string} NUMBER references the number primitive
6
- * @property {string} BOOLEAN references the boolean primitive
7
- * @property {string} BIGINT references the bigint primitive
8
- * @enum Primitives
9
- * @readonly
10
- * @memberOf module:decorator-validation
11
- */
12
- export declare enum Primitives {
13
- /** references the string primitive */
14
- STRING = "string",
15
- /** references the number primitive */
16
- NUMBER = "number",
17
- /** references the boolean primitive */
18
- BOOLEAN = "boolean",
19
- /** references the bigint primitive */
20
- BIGINT = "bigint"
21
- }
22
- /**
23
- * @description Reserved model names which are excluded from model rebuilding.
24
- * @summary References the Reserved model names to ignore during Model rebuilding to avoid interfering with native types and special cases.
25
- * @property {string} STRING
26
- * @property {string} OBJECT
27
- * @property {string} NUMBER
28
- * @property {string} BOOLEAN
29
- * @property {string} BIGINT
30
- * @property {string} DATE
31
- * @enum ReservedModels
32
- * @readonly
33
- * @memberOf module:decorator-validation
34
- */
35
- export declare const ReservedModels: {
36
- /** reserved name for string */
37
- STRING: StringConstructor;
38
- /** reserved name for object */
39
- OBJECT: ObjectConstructor;
40
- /** reserved name for number */
41
- NUMBER: NumberConstructor;
42
- /** reserved name for boolean */
43
- BOOLEAN: BooleanConstructor;
44
- /** reserved name for bigint */
45
- BIGINT: BigIntConstructor;
46
- /** reserved name for Date */
47
- DATE: DateConstructor;
48
- };
49
- /**
50
- * @description Basic supported JavaScript types used by the validation system.
51
- * @summary References the basic supported JS types as strings that can be used for type checking and metadata.
52
- * @typedef {Object} JsTypes
53
- * @property {"string"} string String primitive identifier
54
- * @property {"array"} array Array type identifier
55
- * @property {"number"} number Number primitive identifier
56
- * @property {"boolean"} boolean Boolean primitive identifier
57
- * @property {"symbol"} symbol Symbol primitive identifier
58
- * @property {"function"} function Function type identifier
59
- * @property {"object"} object Object type identifier
60
- * @property {"undefined"} undefined Undefined type identifier
61
- * @property {"null"} null Null value identifier
62
- * @property {"bigint"} BIGINT BigInt primitive identifier
63
- * @memberOf module:decorator-validation
64
- */
65
- export declare const jsTypes: string[];
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/model/constants.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,IAAY,UASX;AATD,WAAY,UAAU;IACpB,sCAAsC;IACtC,+BAAiB,CAAA;IACjB,sCAAsC;IACtC,+BAAiB,CAAA;IACjB,uCAAuC;IACvC,iCAAmB,CAAA;IACnB,sCAAsC;IACtC,+BAAiB,CAAA;AACnB,CAAC,EATW,UAAU,0BAAV,UAAU,QASrB;AAED;;;;;;;;;;;;GAYG;AACU,QAAA,cAAc,GAAG;IAC5B,+BAA+B;IAC/B,MAAM,EAAE,MAAM;IACd,+BAA+B;IAC/B,MAAM,EAAE,MAAM;IACd,+BAA+B;IAC/B,MAAM,EAAE,MAAM;IACd,gCAAgC;IAChC,OAAO,EAAE,OAAO;IAChB,+BAA+B;IAC/B,MAAM,EAAE,MAAM;IACd,6BAA6B;IAC7B,IAAI,EAAE,IAAI;CACX,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACU,QAAA,OAAO,GAAG;IACrB,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,WAAW;IACX,MAAM;IACN,QAAQ;CACT,CAAC"}
@@ -1,46 +0,0 @@
1
- import { Model } from "./Model";
2
- /**
3
- * @description Helper function to create an instance by invoking a constructor with dynamic arguments.
4
- * @summary Overrides standard construction patterns by wrapping the given constructor to allow spread argument invocation while preserving the prototype chain.
5
- * @template M the model instance type
6
- * @param {any} constructor The constructor function to invoke.
7
- * @param {...any[]} args Optional arguments to pass to the constructor.
8
- * @return {M} The newly constructed instance.
9
- * @function construct
10
- * @memberOf module:decorator-validation
11
- */
12
- export declare function construct<M extends Model>(constructor: any, ...args: any[]): M;
13
- /**
14
- * @description Recursively finds the last prototype in the chain before reaching Object.prototype.
15
- * @summary Walks up the prototype chain to locate the most derived prototype that still precedes the base Object prototype.
16
- * @param {object} obj The object whose prototype chain will be inspected.
17
- * @return {object} The last prototype before Object.prototype, or the input object if its prototype is Object.prototype.
18
- * @function findLastProtoBeforeObject
19
- * @memberOf module:decorator-validation
20
- */
21
- export declare function findLastProtoBeforeObject(obj: object): object;
22
- /**
23
- * @description Binds the Model class as the root prototype of the provided instance when not already a Model.
24
- * @summary Ensures objects created outside of the Model inheritance chain gain Model as their ultimate prototype to access model utilities.
25
- * @param {unknown} obj The object to bind to the Model prototype chain.
26
- * @return {void}
27
- * @function bindModelPrototype
28
- * @mermaid
29
- * sequenceDiagram
30
- * participant Caller
31
- * participant Fn as bindModelPrototype
32
- * participant M as Model.prototype
33
- * Caller->>Fn: obj
34
- * alt obj instanceof Model
35
- * Fn-->>Caller: return
36
- * else obj chain ends at Object.prototype
37
- * Fn->>Fn: setPrototypeOf(obj, M)
38
- * Fn-->>Caller: return
39
- * else deep prototype chain
40
- * Fn->>Fn: walk prototypes
41
- * Fn->>Fn: setPrototypeOf(last, M)
42
- * Fn-->>Caller: return
43
- * end
44
- * @memberOf module:decorator-validation
45
- */
46
- export declare function bindModelPrototype(obj: unknown): void;
@@ -1 +0,0 @@
1
- {"version":3,"file":"construction.js","sourceRoot":"","sources":["../../src/model/construction.ts"],"names":[],"mappings":";;AAYA,8BAOC;AAUD,8DASC;AA0BD,gDAqBC;AArFD,uCAAgC;AAEhC;;;;;;;;;GASG;AACH,SAAgB,SAAS,CACvB,WAAgB,EAChB,GAAG,IAAW;IAEd,MAAM,OAAO,GAAG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,IAAI,GAAG,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC9C,IACE,IAAI,KAAK,MAAM,CAAC,SAAS;YACzB,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,SAAS,EAChD,CAAC;YACD,OAAO,aAAa,CAAC,SAAS,EAAE,aAAK,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC7D,CAAC"}
@@ -1,47 +0,0 @@
1
- /**
2
- * @description Base decorator for model classes.
3
- * @summary This decorator wraps the original constructor to bind the Model prototype, run a builder function, and register the model.
4
- * @param {any} original The original constructor of the class.
5
- * @return {any} The new constructor with added model functionality.
6
- * @function modelBaseDecorator
7
- * @memberOf module:decorator-validation
8
- */
9
- export declare function modelBaseDecorator(original: any): any;
10
- /**
11
- * @summary Defines a class as a Model class
12
- * @description
13
- *
14
- * - Registers the class under the model registry so it can be easily rebuilt;
15
- * - Overrides the class constructor;
16
- * - Runs the global {@link ModelBuilderFunction} if defined;
17
- *
18
- * @function model
19
- *
20
- * @category Class Decorators
21
- */
22
- export declare function model(): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
23
- /**
24
- * @summary Defines the hashing algorithm to use on the model
25
- * @description
26
- *
27
- * - Registers the class under the model registry so it can be easily rebuilt;
28
- * - Overrides the class constructor;
29
- * - Runs the global {@link ModelBuilderFunction} if defined;
30
- *
31
- * @param {string} algorithm the algorithm to use
32
- *
33
- * @function hashedBy
34
- *
35
- * @category Class Decorators
36
- */
37
- export declare function hashedBy(algorithm: string, ...args: any[]): (model: any, prop?: any, descriptor?: PropertyDescriptor | number) => void;
38
- /**
39
- * @summary Defines the serialization algorithm to use on the model
40
- *
41
- * @param {string} serializer the algorithm to use
42
- *
43
- * @function serializedBy
44
- *
45
- * @category Class Decorators
46
- */
47
- export declare function serializedBy(serializer: string, ...args: any[]): (model: any, prop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C;AACxB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,KAAK;IACnB,MAAM,GAAG,GAAG,qBAAS,CAAC,KAAK,CAAC;IAC5B,OAAO,uBAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,KAAK,EAAE,CAAC;AAChE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,QAAQ,CAAC,SAAiB,EAAE,GAAG,IAAW;IACxD,OAAO,IAAA,qBAAQ,EAAC,qBAAS,CAAC,OAAO,EAAE;QACjC,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAAC,UAAkB,EAAE,GAAG,IAAW;IAC7D,OAAO,IAAA,qBAAQ,EAAC,qBAAS,CAAC,aAAa,EAAE;QACvC,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC"}
@@ -1,10 +0,0 @@
1
- export * from "./constants";
2
- export * from "./construction";
3
- export * from "./decorators";
4
- export * from "./ModelRegistry";
5
- export * from "./Model";
6
- export * from "./ModelErrorDefinition";
7
- export * from "./Builder";
8
- export * from "./types";
9
- export * from "./validation";
10
- export * from "./utils";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA4B;AAC5B,qDAA+B;AAC/B,mDAA6B;AAC7B,sDAAgC,CAAC,mCAAmC;AACpE,8CAAwB;AACxB,6DAAuC;AACvC,gDAA0B;AAC1B,8CAAwB;AACxB,mDAA6B;AAC7B,8CAAwB"}
@@ -1,145 +0,0 @@
1
- import type { ConditionalAsync } from "../types";
2
- import { ModelErrorDefinition } from "./ModelErrorDefinition";
3
- import { Model } from "./Model";
4
- /**
5
- * @description Function type for building model instances from objects
6
- * @summary Type definition for a model builder function that populates model properties
7
- * @template T
8
- * @param {T} self - The target model instance to populate
9
- * @param {T | Record<string, any>} [obj] - The source object containing properties to copy
10
- * @return {T} - The populated model instance
11
- * @typedef ModelBuilderFunction
12
- * @memberOf module:decorator-validation
13
- */
14
- export type ModelBuilderFunction = <T extends Model>(self: T, obj?: T | Record<string, any>) => T;
15
- /**
16
- * @description Type representing valid argument types for model constructors
17
- * @summary Definition of a Model Constructor Argument that can be a complete model, partial model, or plain object
18
- * @template T
19
- * @typedef ModelArg
20
- * @memberOf module:decorator-validation
21
- * @see ModelConstructor
22
- */
23
- export type ModelArg<T> = T | Partial<T> | Record<string, any>;
24
- /**
25
- * @description Specialized constructor type for Model classes
26
- * @summary Definition of a Model Constructor that creates instances of Model subclasses
27
- * @template T
28
- * @param {ModelArg<T>} [model] - Initial data to populate the model with
29
- * @param {any[]} [args] - Additional constructor arguments
30
- * @return {T} - An instance of the model class
31
- * @typedef ModelConstructor
32
- * @memberOf module:decorator-validation
33
- */
34
- export type ModelConstructor<T extends Model> = {
35
- new (model?: ModelArg<T>, ...args: any[]): T;
36
- };
37
- /**
38
- * @description Interface for objects that can be validated.
39
- * @summary Defines the Validation API for validation behavior on models, supporting both synchronous and asynchronous validations.
40
- * Implementers must provide a `hasErrors` method that performs the validation and returns either validation errors or undefined if validation passes.
41
- *
42
- * @template Async - A boolean flag indicating whether the validation is asynchronous (`true`) or synchronous (`false`).
43
- *
44
- * @param {any[]} [args] - Optional arguments to control validation behavior passed to the validation method.
45
- *
46
- * @interface Validatable
47
- * @category Model
48
- * @memberOf module:decorator-validation
49
- *
50
- * @example
51
- * ```typescript
52
- * // Synchronous validation example
53
- * class SyncModel implements Validatable<false> {
54
- * hasErrors(...args: any[]): ModelErrorDefinition | undefined {
55
- * // perform synchronous validation logic
56
- * return undefined; // or return errors if invalid
57
- * }
58
- * }
59
- *
60
- * // Asynchronous validation example
61
- * class AsyncModel implements Validatable<true> {
62
- * async hasErrors(...args: any[]): Promise<ModelErrorDefinition | undefined> {
63
- * // perform asynchronous validation logic
64
- * return undefined; // or return errors if invalid
65
- * }
66
- * }
67
- * ```
68
- */
69
- export interface Validatable<Async extends boolean = false> {
70
- /**
71
- * @description Validates the object against its validation rules.
72
- * @summary Validates the model and returns the {@link ModelErrorDefinition} if any errors exist, or `undefined` if no errors.
73
- *
74
- * @param {any[]} [args] - Optional arguments that may influence validation logic.
75
- * @return {ConditionalAsync<Async, ModelErrorDefinition | undefined>} Validation errors or undefined, conditionally wrapped in a Promise if asynchronous.
76
- *
77
- * @method
78
- */
79
- hasErrors(...args: any[]): ConditionalAsync<Async, ModelErrorDefinition | undefined>;
80
- }
81
- /**
82
- * @description Interface for objects that can be serialized to string
83
- * @summary Defines the serialization API for model objects
84
- * @interface Serializable
85
- * @memberOf module:decorator-validation
86
- * @category Model
87
- */
88
- export interface Serializable {
89
- /**
90
- * @description Converts the object to a serialized string representation
91
- * @summary Serializes the model to a string format
92
- * @return {string} - The serialized string representation
93
- * @method
94
- */
95
- serialize(...args: any[]): string;
96
- }
97
- /**
98
- * @description Interface for objects that can generate a hash representation
99
- * @summary Defines the hashing API for model objects
100
- * @interface Hashable
101
- * @memberOf module:decorator-validation
102
- * @category Model
103
- */
104
- export interface Hashable {
105
- /**
106
- * @description Generates a unique hash string for the object
107
- * @summary Creates a hash string representation of the object
108
- * @return {string} - Hash value representing the object
109
- * @method
110
- */
111
- hash(...args: any[]): string;
112
- }
113
- /**
114
- * @description Interface for objects that can be compared with other objects
115
- * @summary Defines the equality comparison API for model objects
116
- * @template T
117
- * @interface Comparable
118
- * @memberOf module:decorator-validation
119
- * @category Model
120
- */
121
- export interface Comparable {
122
- /**
123
- * @description Determines if this object is equal to another object
124
- * @summary Compares this object with another for equality
125
- * @param {T} other - The object to compare with
126
- * @param {any[]} [args] - Additional arguments for comparison
127
- * @return {boolean} - True if the objects are equal, false otherwise
128
- * @method
129
- */
130
- equals<T extends Model>(this: T, other: T, ...args: any[]): boolean;
131
- compare<T extends Model>(this: T, other: T, ...args: any[]): Comparison<T> | undefined;
132
- }
133
- export type SetterKeyFor<OBJ, K extends keyof OBJ> = `set${Capitalize<string & K>}`;
134
- export type SetterFor<OBJ, K extends keyof OBJ, R> = (value: OBJ[K]) => R;
135
- export type Builder<OUT, ARGS extends any[] = any[], IN = OUT> = {
136
- [K in keyof OUT as K extends keyof Model | "build" ? never : K]: OUT[K];
137
- } & {
138
- [K in keyof OUT as K extends keyof Model | "build" ? never : SetterKeyFor<OUT, K>]: SetterFor<OUT, K, IN>;
139
- } & {
140
- build: (...args: ARGS) => OUT | Promise<OUT>;
141
- };
142
- export type Comparison<M, K extends keyof M = keyof M> = Record<K, {
143
- other: M[K] | undefined;
144
- current: M[K] | undefined;
145
- }>;
@@ -1,13 +0,0 @@
1
- import { ConditionalAsync } from "../types";
2
- /**
3
- * Wraps a value in a Promise if the `async` flag is true.
4
- *
5
- * @template T - The type of the value being wrapped.
6
- * @template Async - A boolean type that determines if the result should be wrapped in a Promise.
7
- *
8
- * @param value - The value to return directly or wrap in a Promise.
9
- * @param async - If true, the value is wrapped in a resolved Promise. If false or undefined, the value is returned as-is.
10
- *
11
- * @returns The original value or a Promise resolving to it, depending on the `async` flag.
12
- */
13
- export declare function toConditionalPromise<T, Async extends boolean>(value: T, async?: Async): ConditionalAsync<Async, T>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/model/utils.ts"],"names":[],"mappings":";;AAaA,oDAKC;AAhBD;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAClC,KAAQ,EACR,KAAa;IAEb,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAA+B,CAAC;AAChF,CAAC"}
@@ -1,92 +0,0 @@
1
- import { ModelErrorDefinition } from "./ModelErrorDefinition";
2
- import type { Model } from "./Model";
3
- import { ConditionalAsync } from "../types";
4
- export declare function validateChildValue<M extends Model>(prop: string, childValue: any, parentModel: M, allowedTypes: string[], async: boolean, ...propsToIgnore: string[]): string | undefined | ModelErrorDefinition | Promise<string | undefined | ModelErrorDefinition>;
5
- /**
6
- * @description Retrieves nested properties to ignore for child validation
7
- * @param parentProp - The property of the parent model
8
- * @param propsToIgnore - Properties to ignore from the parent model
9
- * @returns An array of properties to ignore for the child model
10
- */
11
- export declare function getChildNestedPropsToIgnore(parentProp: string, ...propsToIgnore: string[]): string[];
12
- export declare function validateDecorator<M extends Model, Async extends boolean = false>(model: M, value: any, decorator: any, async?: Async): ConditionalAsync<Async, string | undefined>;
13
- /**
14
- * @description
15
- * Executes validation logic for a set of decorators applied to a model's property, handling both
16
- * synchronous and asynchronous validations, including support for nested validations and lists.
17
- *
18
- * @summary
19
- * Iterates over an array of decorator metadata objects and applies each validation rule to the
20
- * provided value. For list decorators (`ValidationKeys.LIST`), it performs element-wise validation,
21
- * supporting nested model validation and type checks. If the `async` flag is set, asynchronous
22
- * validation is supported using `Promise.all`. The result is a record mapping validation keys to
23
- * error messages, or `undefined` if no errors are found.
24
- *
25
- * @template M - A type parameter extending `Model`, representing the model type being validated.
26
- * @template Async - A boolean indicating whether validation should be performed asynchronously.
27
- *
28
- * @param {M} model - The model instance that the validation is associated with.
29
- * @param {string} prop - The model field name
30
- * @param {any} value - The value to be validated against the provided decorators.
31
- * @param {DecoratorMetadataAsync} decorators - An object of metadata representing validation decorators.
32
- * @param {Async} [async] - Optional flag indicating whether validation should be performed asynchronously.
33
- *
34
- * @return {ConditionalAsync<Async, Record<string, string>> | undefined}
35
- * Returns either a record of validation errors (keyed by the decorator key) or `undefined` if no errors are found.
36
- * If `async` is true, the return value is a Promise resolving to the same structure.
37
- *
38
- * @function validateDecorators
39
- */
40
- export declare function validateDecorators<M extends Model, Async extends boolean = false>(model: M, prop: string, value: any, decorators: any, async?: Async, ...propsToIgnore: string[]): ConditionalAsync<Async, Record<string, string> | undefined>;
41
- /**
42
- * @function validate
43
- * @template M
44
- * @template Async
45
- * @memberOf module:decorator-validation
46
- * @category Model
47
- *
48
- * @description
49
- * Validates the properties of a {@link Model} instance using registered decorators.
50
- * Supports both synchronous and asynchronous validation flows, depending on the `async` flag.
51
- *
52
- * @summary
53
- * This function inspects a given model object, identifies decorated properties that require validation,
54
- * and applies the corresponding validation rules. It also supports nested model validation and gracefully
55
- * merges any validation errors. For collections (Array/Set), it enforces the presence of the `@list` decorator
56
- * and checks the type of elements. If a property is a nested model, it will call `hasErrors` on it and flatten
57
- * the nested error keys using dot notation.
58
- *
59
- * @param {M} model - The model instance to be validated. Must extend from {@link Model}.
60
- * @param {Async} [async] - A flag indicating whether validation should be asynchronous.
61
- * @param {...string} propsToIgnore - A variadic list of property names that should be skipped during validation.
62
- *
63
- * @returns {ConditionalAsync<Async, ModelErrorDefinition | undefined>}
64
- * Returns either a {@link ModelErrorDefinition} containing validation errors,
65
- * or `undefined` if no errors are found. When `async` is `true`, returns a Promise.
66
- *
67
- * @see {@link Model}
68
- * @see {@link ModelErrorDefinition}
69
- * @see {@link validateDecorators}
70
- * @see {@link getValidatableProperties}
71
- *
72
- * @mermaid
73
- * sequenceDiagram
74
- * participant Caller
75
- * participant validate
76
- * participant getValidatableProperties
77
- * participant validateDecorators
78
- * participant ModelInstance
79
- * Caller->>validate: call with obj, async, propsToIgnore
80
- * validate->>getValidatableProperties: retrieve decorated props
81
- * loop for each property
82
- * validate->>validateDecorators: validate using decorators
83
- * alt is nested model
84
- * validate->>ModelInstance: call hasErrors()
85
- * end
86
- * end
87
- * alt async
88
- * validate->>validate: Promise.allSettled for errors
89
- * end
90
- * validate-->>Caller: return ModelErrorDefinition | undefined
91
- */
92
- export declare function validate<M extends Model<boolean>, Async extends boolean = false>(model: M, async: Async, ...propsToIgnore: string[]): ConditionalAsync<Async, ModelErrorDefinition | undefined>;