@decaf-ts/decorator-validation 1.15.0 → 1.17.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 (327) hide show
  1. package/lib/cjs/constants/errors.cjs +1 -0
  2. package/lib/cjs/constants/errors.cjs.map +1 -0
  3. package/lib/cjs/constants/index.cjs +1 -0
  4. package/lib/cjs/constants/index.cjs.map +1 -0
  5. package/lib/cjs/constants/validation.cjs +1 -0
  6. package/lib/cjs/constants/validation.cjs.map +1 -0
  7. package/lib/cjs/index.cjs +2 -1
  8. package/lib/cjs/index.cjs.map +1 -0
  9. package/lib/cjs/model/Builder.cjs +49 -48
  10. package/lib/cjs/model/Builder.cjs.map +1 -0
  11. package/lib/cjs/model/Model.cjs +31 -30
  12. package/lib/cjs/model/Model.cjs.map +1 -0
  13. package/lib/cjs/model/ModelErrorDefinition.cjs +1 -0
  14. package/lib/cjs/model/ModelErrorDefinition.cjs.map +1 -0
  15. package/lib/cjs/model/ModelRegistry.cjs +7 -6
  16. package/lib/cjs/model/ModelRegistry.cjs.map +1 -0
  17. package/lib/cjs/model/constants.cjs +2 -13
  18. package/lib/cjs/model/constants.cjs.map +1 -0
  19. package/lib/cjs/model/construction.cjs +5 -4
  20. package/lib/cjs/model/construction.cjs.map +1 -0
  21. package/lib/cjs/model/decorators.cjs +12 -11
  22. package/lib/cjs/model/decorators.cjs.map +1 -0
  23. package/lib/cjs/model/index.cjs +1 -0
  24. package/lib/cjs/model/index.cjs.map +1 -0
  25. package/lib/cjs/model/types.cjs +1 -0
  26. package/lib/cjs/model/types.cjs.map +1 -0
  27. package/lib/cjs/model/utils.cjs +1 -0
  28. package/lib/cjs/model/utils.cjs.map +1 -0
  29. package/lib/cjs/model/validation.cjs +33 -32
  30. package/lib/cjs/model/validation.cjs.map +1 -0
  31. package/lib/cjs/overrides/Metadata.cjs +1 -0
  32. package/lib/cjs/overrides/Metadata.cjs.map +1 -0
  33. package/lib/cjs/overrides/index.cjs +1 -0
  34. package/lib/cjs/overrides/index.cjs.map +1 -0
  35. package/lib/cjs/overrides/overrides.cjs +20 -19
  36. package/lib/cjs/overrides/overrides.cjs.map +1 -0
  37. package/lib/cjs/overrides/types.cjs +1 -0
  38. package/lib/cjs/overrides/types.cjs.map +1 -0
  39. package/lib/cjs/types/index.cjs +1 -0
  40. package/lib/cjs/types/index.cjs.map +1 -0
  41. package/lib/cjs/types/validation.cjs +1 -0
  42. package/lib/cjs/types/{validation.js.map → validation.cjs.map} +1 -1
  43. package/lib/cjs/utils/DateBuilder.cjs +1 -0
  44. package/lib/cjs/utils/DateBuilder.cjs.map +1 -0
  45. package/lib/cjs/utils/PathProxy.cjs +9 -8
  46. package/lib/cjs/utils/PathProxy.cjs.map +1 -0
  47. package/lib/cjs/utils/constants.cjs +2 -21
  48. package/lib/cjs/utils/constants.cjs.map +1 -0
  49. package/lib/cjs/utils/dates.cjs +9 -8
  50. package/lib/cjs/utils/dates.cjs.map +1 -0
  51. package/lib/cjs/utils/equality.cjs +1 -0
  52. package/lib/cjs/utils/equality.cjs.map +1 -0
  53. package/lib/cjs/utils/hashing.cjs +6 -3
  54. package/lib/cjs/utils/hashing.cjs.map +1 -0
  55. package/lib/cjs/utils/index.cjs +1 -0
  56. package/lib/cjs/utils/index.cjs.map +1 -0
  57. package/lib/cjs/utils/registry.cjs +1 -0
  58. package/lib/cjs/utils/registry.cjs.map +1 -0
  59. package/lib/cjs/utils/serialization.cjs +3 -2
  60. package/lib/cjs/utils/serialization.cjs.map +1 -0
  61. package/lib/cjs/utils/serializers.cjs +8 -7
  62. package/lib/cjs/utils/serializers.cjs.map +1 -0
  63. package/lib/cjs/utils/strings.cjs +1 -0
  64. package/lib/cjs/utils/strings.cjs.map +1 -0
  65. package/lib/cjs/utils/types.cjs +1 -0
  66. package/lib/cjs/utils/types.cjs.map +1 -0
  67. package/lib/cjs/validation/Validation.cjs +9 -8
  68. package/lib/cjs/validation/Validation.cjs.map +1 -0
  69. package/lib/cjs/validation/Validators/AsyncValidator.cjs +5 -4
  70. package/lib/cjs/validation/Validators/AsyncValidator.cjs.map +1 -0
  71. package/lib/cjs/validation/Validators/BaseValidator.cjs +8 -7
  72. package/lib/cjs/validation/Validators/BaseValidator.cjs.map +1 -0
  73. package/lib/cjs/validation/Validators/DateValidator.cjs +17 -11
  74. package/lib/cjs/validation/Validators/DateValidator.cjs.map +1 -0
  75. package/lib/cjs/validation/Validators/DiffValidator.cjs +21 -15
  76. package/lib/cjs/validation/Validators/DiffValidator.cjs.map +1 -0
  77. package/lib/cjs/validation/Validators/EmailValidator.cjs +18 -12
  78. package/lib/cjs/validation/Validators/EmailValidator.cjs.map +1 -0
  79. package/lib/cjs/validation/Validators/EqualsValidator.cjs +21 -15
  80. package/lib/cjs/validation/Validators/EqualsValidator.cjs.map +1 -0
  81. package/lib/cjs/validation/Validators/GreaterThanOrEqualValidator.cjs +24 -18
  82. package/lib/cjs/validation/Validators/GreaterThanOrEqualValidator.cjs.map +1 -0
  83. package/lib/cjs/validation/Validators/GreaterThanValidator.cjs +21 -15
  84. package/lib/cjs/validation/Validators/GreaterThanValidator.cjs.map +1 -0
  85. package/lib/cjs/validation/Validators/LessThanOrEqualValidator.cjs +24 -18
  86. package/lib/cjs/validation/Validators/LessThanOrEqualValidator.cjs.map +1 -0
  87. package/lib/cjs/validation/Validators/LessThanValidator.cjs +21 -15
  88. package/lib/cjs/validation/Validators/LessThanValidator.cjs.map +1 -0
  89. package/lib/cjs/validation/Validators/ListValidator.cjs +17 -11
  90. package/lib/cjs/validation/Validators/ListValidator.cjs.map +1 -0
  91. package/lib/cjs/validation/Validators/MaxLengthValidator.cjs +19 -13
  92. package/lib/cjs/validation/Validators/MaxLengthValidator.cjs.map +1 -0
  93. package/lib/cjs/validation/Validators/MaxValidator.cjs +17 -11
  94. package/lib/cjs/validation/Validators/MaxValidator.cjs.map +1 -0
  95. package/lib/cjs/validation/Validators/MinLengthValidator.cjs +19 -13
  96. package/lib/cjs/validation/Validators/MinLengthValidator.cjs.map +1 -0
  97. package/lib/cjs/validation/Validators/MinValidator.cjs +17 -11
  98. package/lib/cjs/validation/Validators/MinValidator.cjs.map +1 -0
  99. package/lib/cjs/validation/Validators/OptionValidator.cjs +17 -11
  100. package/lib/cjs/validation/Validators/OptionValidator.cjs.map +1 -0
  101. package/lib/cjs/validation/Validators/PasswordValidator.cjs +18 -12
  102. package/lib/cjs/validation/Validators/PasswordValidator.cjs.map +1 -0
  103. package/lib/cjs/validation/Validators/PatternValidator.cjs +17 -11
  104. package/lib/cjs/validation/Validators/PatternValidator.cjs.map +1 -0
  105. package/lib/cjs/validation/Validators/RequiredValidator.cjs +17 -11
  106. package/lib/cjs/validation/Validators/RequiredValidator.cjs.map +1 -0
  107. package/lib/cjs/validation/Validators/StepValidator.cjs +17 -11
  108. package/lib/cjs/validation/Validators/StepValidator.cjs.map +1 -0
  109. package/lib/cjs/validation/Validators/TypeValidator.cjs +23 -17
  110. package/lib/cjs/validation/Validators/TypeValidator.cjs.map +1 -0
  111. package/lib/cjs/validation/Validators/URLValidator.cjs +18 -12
  112. package/lib/cjs/validation/Validators/URLValidator.cjs.map +1 -0
  113. package/lib/cjs/validation/Validators/Validator.cjs +5 -4
  114. package/lib/cjs/validation/Validators/Validator.cjs.map +1 -0
  115. package/lib/cjs/validation/Validators/ValidatorRegistry.cjs +4 -3
  116. package/lib/cjs/validation/Validators/ValidatorRegistry.cjs.map +1 -0
  117. package/lib/cjs/validation/Validators/constants.cjs +3 -2
  118. package/lib/cjs/validation/Validators/constants.cjs.map +1 -0
  119. package/lib/cjs/validation/Validators/decorators.cjs +5 -4
  120. package/lib/cjs/validation/Validators/decorators.cjs.map +1 -0
  121. package/lib/cjs/validation/Validators/index.cjs +1 -0
  122. package/lib/cjs/validation/Validators/index.cjs.map +1 -0
  123. package/lib/cjs/validation/Validators/utils.cjs +14 -13
  124. package/lib/cjs/validation/Validators/utils.cjs.map +1 -0
  125. package/lib/cjs/validation/decorators.cjs +70 -69
  126. package/lib/cjs/validation/decorators.cjs.map +1 -0
  127. package/lib/cjs/validation/index.cjs +1 -0
  128. package/lib/cjs/validation/index.cjs.map +1 -0
  129. package/lib/cjs/validation/types.cjs +2 -1
  130. package/lib/cjs/validation/types.cjs.map +1 -0
  131. package/lib/esm/index.js +1 -1
  132. package/lib/types/constants/errors.d.cts +17 -0
  133. package/lib/types/constants/errors.d.mts +17 -0
  134. package/lib/types/constants/index.d.cts +2 -0
  135. package/lib/types/constants/index.d.mts +2 -0
  136. package/lib/types/constants/validation.d.cts +16 -0
  137. package/lib/types/constants/validation.d.mts +16 -0
  138. package/lib/types/index.d.cts +20 -0
  139. package/lib/types/index.d.mts +20 -0
  140. package/lib/types/index.d.ts +1 -1
  141. package/lib/types/model/Builder.d.cts +86 -0
  142. package/lib/types/model/Builder.d.mts +86 -0
  143. package/lib/types/model/Model.d.cts +286 -0
  144. package/lib/types/model/Model.d.mts +286 -0
  145. package/lib/types/model/ModelErrorDefinition.d.cts +22 -0
  146. package/lib/types/model/ModelErrorDefinition.d.mts +22 -0
  147. package/lib/types/model/ModelRegistry.d.cts +181 -0
  148. package/lib/types/model/ModelRegistry.d.mts +181 -0
  149. package/lib/types/model/constants.d.cts +65 -0
  150. package/lib/types/model/constants.d.mts +65 -0
  151. package/lib/types/model/construction.d.cts +46 -0
  152. package/lib/types/model/construction.d.mts +46 -0
  153. package/lib/types/model/decorators.d.cts +47 -0
  154. package/lib/types/model/decorators.d.mts +47 -0
  155. package/lib/types/model/index.d.cts +10 -0
  156. package/lib/types/model/index.d.mts +10 -0
  157. package/lib/types/model/types.d.cts +145 -0
  158. package/lib/types/model/types.d.mts +145 -0
  159. package/lib/types/model/utils.d.cts +13 -0
  160. package/lib/types/model/utils.d.mts +13 -0
  161. package/lib/types/model/validation.d.cts +92 -0
  162. package/lib/types/model/validation.d.mts +92 -0
  163. package/lib/types/overrides/Metadata.d.cts +132 -0
  164. package/lib/types/overrides/Metadata.d.mts +132 -0
  165. package/lib/types/overrides/index.d.cts +4 -0
  166. package/lib/types/overrides/index.d.mts +4 -0
  167. package/lib/types/overrides/overrides.d.cts +1 -0
  168. package/lib/types/overrides/overrides.d.mts +1 -0
  169. package/lib/types/overrides/types.d.cts +17 -0
  170. package/lib/types/overrides/types.d.mts +17 -0
  171. package/lib/types/types/index.d.cts +1 -0
  172. package/lib/types/types/index.d.mts +1 -0
  173. package/lib/types/types/validation.d.cts +28 -0
  174. package/lib/types/types/validation.d.mts +28 -0
  175. package/lib/types/utils/DateBuilder.d.cts +121 -0
  176. package/lib/types/utils/DateBuilder.d.mts +121 -0
  177. package/lib/types/utils/PathProxy.d.cts +43 -0
  178. package/lib/types/utils/PathProxy.d.mts +43 -0
  179. package/lib/types/utils/constants.d.cts +32 -0
  180. package/lib/types/utils/constants.d.mts +32 -0
  181. package/lib/types/utils/dates.d.cts +86 -0
  182. package/lib/types/utils/dates.d.mts +86 -0
  183. package/lib/types/utils/equality.d.cts +56 -0
  184. package/lib/types/utils/equality.d.mts +56 -0
  185. package/lib/types/utils/hashing.d.cts +82 -0
  186. package/lib/types/utils/hashing.d.mts +82 -0
  187. package/lib/types/utils/index.d.cts +11 -0
  188. package/lib/types/utils/index.d.mts +11 -0
  189. package/lib/types/utils/registry.d.cts +68 -0
  190. package/lib/types/utils/registry.d.mts +68 -0
  191. package/lib/types/utils/serialization.d.cts +12 -0
  192. package/lib/types/utils/serialization.d.mts +12 -0
  193. package/lib/types/utils/serializers.d.cts +41 -0
  194. package/lib/types/utils/serializers.d.mts +41 -0
  195. package/lib/types/utils/strings.d.cts +25 -0
  196. package/lib/types/utils/strings.d.mts +25 -0
  197. package/lib/types/utils/types.d.cts +35 -0
  198. package/lib/types/utils/types.d.mts +35 -0
  199. package/lib/types/validation/Validation.d.cts +53 -0
  200. package/lib/types/validation/Validation.d.mts +53 -0
  201. package/lib/types/validation/Validators/AsyncValidator.d.cts +72 -0
  202. package/lib/types/validation/Validators/AsyncValidator.d.mts +72 -0
  203. package/lib/types/validation/Validators/BaseValidator.d.cts +118 -0
  204. package/lib/types/validation/Validators/BaseValidator.d.mts +118 -0
  205. package/lib/types/validation/Validators/DateValidator.d.cts +60 -0
  206. package/lib/types/validation/Validators/DateValidator.d.mts +60 -0
  207. package/lib/types/validation/Validators/DiffValidator.d.cts +29 -0
  208. package/lib/types/validation/Validators/DiffValidator.d.mts +29 -0
  209. package/lib/types/validation/Validators/EmailValidator.d.cts +60 -0
  210. package/lib/types/validation/Validators/EmailValidator.d.mts +60 -0
  211. package/lib/types/validation/Validators/EqualsValidator.d.cts +29 -0
  212. package/lib/types/validation/Validators/EqualsValidator.d.mts +29 -0
  213. package/lib/types/validation/Validators/GreaterThanOrEqualValidator.d.cts +29 -0
  214. package/lib/types/validation/Validators/GreaterThanOrEqualValidator.d.mts +29 -0
  215. package/lib/types/validation/Validators/GreaterThanValidator.d.cts +29 -0
  216. package/lib/types/validation/Validators/GreaterThanValidator.d.mts +29 -0
  217. package/lib/types/validation/Validators/LessThanOrEqualValidator.d.cts +29 -0
  218. package/lib/types/validation/Validators/LessThanOrEqualValidator.d.mts +29 -0
  219. package/lib/types/validation/Validators/LessThanValidator.d.cts +29 -0
  220. package/lib/types/validation/Validators/LessThanValidator.d.mts +29 -0
  221. package/lib/types/validation/Validators/ListValidator.d.cts +66 -0
  222. package/lib/types/validation/Validators/ListValidator.d.mts +66 -0
  223. package/lib/types/validation/Validators/MaxLengthValidator.d.cts +29 -0
  224. package/lib/types/validation/Validators/MaxLengthValidator.d.mts +29 -0
  225. package/lib/types/validation/Validators/MaxValidator.d.cts +74 -0
  226. package/lib/types/validation/Validators/MaxValidator.d.mts +74 -0
  227. package/lib/types/validation/Validators/MinLengthValidator.d.cts +29 -0
  228. package/lib/types/validation/Validators/MinLengthValidator.d.mts +29 -0
  229. package/lib/types/validation/Validators/MinValidator.d.cts +74 -0
  230. package/lib/types/validation/Validators/MinValidator.d.mts +74 -0
  231. package/lib/types/validation/Validators/OptionValidator.d.cts +29 -0
  232. package/lib/types/validation/Validators/OptionValidator.d.mts +29 -0
  233. package/lib/types/validation/Validators/PasswordValidator.d.cts +28 -0
  234. package/lib/types/validation/Validators/PasswordValidator.d.mts +28 -0
  235. package/lib/types/validation/Validators/PatternValidator.d.cts +103 -0
  236. package/lib/types/validation/Validators/PatternValidator.d.mts +103 -0
  237. package/lib/types/validation/Validators/RequiredValidator.d.cts +74 -0
  238. package/lib/types/validation/Validators/RequiredValidator.d.mts +74 -0
  239. package/lib/types/validation/Validators/StepValidator.d.cts +29 -0
  240. package/lib/types/validation/Validators/StepValidator.d.mts +29 -0
  241. package/lib/types/validation/Validators/TypeValidator.d.cts +79 -0
  242. package/lib/types/validation/Validators/TypeValidator.d.mts +79 -0
  243. package/lib/types/validation/Validators/URLValidator.d.cts +61 -0
  244. package/lib/types/validation/Validators/URLValidator.d.mts +61 -0
  245. package/lib/types/validation/Validators/Validator.d.cts +65 -0
  246. package/lib/types/validation/Validators/Validator.d.mts +65 -0
  247. package/lib/types/validation/Validators/ValidatorRegistry.d.cts +41 -0
  248. package/lib/types/validation/Validators/ValidatorRegistry.d.mts +41 -0
  249. package/lib/types/validation/Validators/constants.d.cts +157 -0
  250. package/lib/types/validation/Validators/constants.d.mts +157 -0
  251. package/lib/types/validation/Validators/decorators.d.cts +12 -0
  252. package/lib/types/validation/Validators/decorators.d.mts +12 -0
  253. package/lib/types/validation/Validators/index.d.cts +26 -0
  254. package/lib/types/validation/Validators/index.d.mts +26 -0
  255. package/lib/types/validation/Validators/utils.d.cts +75 -0
  256. package/lib/types/validation/Validators/utils.d.mts +75 -0
  257. package/lib/types/validation/decorators.d.cts +313 -0
  258. package/lib/types/validation/decorators.d.mts +313 -0
  259. package/lib/types/validation/index.d.cts +9 -0
  260. package/lib/types/validation/index.d.mts +9 -0
  261. package/lib/types/validation/types.d.cts +309 -0
  262. package/lib/types/validation/types.d.mts +309 -0
  263. package/package.json +4 -4
  264. package/lib/cjs/constants/errors.js.map +0 -1
  265. package/lib/cjs/constants/index.js.map +0 -1
  266. package/lib/cjs/constants/validation.js.map +0 -1
  267. package/lib/cjs/index.js.map +0 -1
  268. package/lib/cjs/model/Builder.js.map +0 -1
  269. package/lib/cjs/model/Model.js.map +0 -1
  270. package/lib/cjs/model/ModelErrorDefinition.js.map +0 -1
  271. package/lib/cjs/model/ModelRegistry.js.map +0 -1
  272. package/lib/cjs/model/constants.js.map +0 -1
  273. package/lib/cjs/model/construction.js.map +0 -1
  274. package/lib/cjs/model/decorators.js.map +0 -1
  275. package/lib/cjs/model/index.js.map +0 -1
  276. package/lib/cjs/model/types.js.map +0 -1
  277. package/lib/cjs/model/utils.js.map +0 -1
  278. package/lib/cjs/model/validation.js.map +0 -1
  279. package/lib/cjs/overrides/Metadata.js.map +0 -1
  280. package/lib/cjs/overrides/index.js.map +0 -1
  281. package/lib/cjs/overrides/overrides.js.map +0 -1
  282. package/lib/cjs/overrides/types.js.map +0 -1
  283. package/lib/cjs/types/index.js.map +0 -1
  284. package/lib/cjs/utils/DateBuilder.js.map +0 -1
  285. package/lib/cjs/utils/PathProxy.js.map +0 -1
  286. package/lib/cjs/utils/constants.js.map +0 -1
  287. package/lib/cjs/utils/dates.js.map +0 -1
  288. package/lib/cjs/utils/equality.js.map +0 -1
  289. package/lib/cjs/utils/hashing.js.map +0 -1
  290. package/lib/cjs/utils/index.js.map +0 -1
  291. package/lib/cjs/utils/registry.js.map +0 -1
  292. package/lib/cjs/utils/serialization.js.map +0 -1
  293. package/lib/cjs/utils/serializers.js.map +0 -1
  294. package/lib/cjs/utils/strings.js.map +0 -1
  295. package/lib/cjs/utils/types.js.map +0 -1
  296. package/lib/cjs/validation/Validation.js.map +0 -1
  297. package/lib/cjs/validation/Validators/AsyncValidator.js.map +0 -1
  298. package/lib/cjs/validation/Validators/BaseValidator.js.map +0 -1
  299. package/lib/cjs/validation/Validators/DateValidator.js.map +0 -1
  300. package/lib/cjs/validation/Validators/DiffValidator.js.map +0 -1
  301. package/lib/cjs/validation/Validators/EmailValidator.js.map +0 -1
  302. package/lib/cjs/validation/Validators/EqualsValidator.js.map +0 -1
  303. package/lib/cjs/validation/Validators/GreaterThanOrEqualValidator.js.map +0 -1
  304. package/lib/cjs/validation/Validators/GreaterThanValidator.js.map +0 -1
  305. package/lib/cjs/validation/Validators/LessThanOrEqualValidator.js.map +0 -1
  306. package/lib/cjs/validation/Validators/LessThanValidator.js.map +0 -1
  307. package/lib/cjs/validation/Validators/ListValidator.js.map +0 -1
  308. package/lib/cjs/validation/Validators/MaxLengthValidator.js.map +0 -1
  309. package/lib/cjs/validation/Validators/MaxValidator.js.map +0 -1
  310. package/lib/cjs/validation/Validators/MinLengthValidator.js.map +0 -1
  311. package/lib/cjs/validation/Validators/MinValidator.js.map +0 -1
  312. package/lib/cjs/validation/Validators/OptionValidator.js.map +0 -1
  313. package/lib/cjs/validation/Validators/PasswordValidator.js.map +0 -1
  314. package/lib/cjs/validation/Validators/PatternValidator.js.map +0 -1
  315. package/lib/cjs/validation/Validators/RequiredValidator.js.map +0 -1
  316. package/lib/cjs/validation/Validators/StepValidator.js.map +0 -1
  317. package/lib/cjs/validation/Validators/TypeValidator.js.map +0 -1
  318. package/lib/cjs/validation/Validators/URLValidator.js.map +0 -1
  319. package/lib/cjs/validation/Validators/Validator.js.map +0 -1
  320. package/lib/cjs/validation/Validators/ValidatorRegistry.js.map +0 -1
  321. package/lib/cjs/validation/Validators/constants.js.map +0 -1
  322. package/lib/cjs/validation/Validators/decorators.js.map +0 -1
  323. package/lib/cjs/validation/Validators/index.js.map +0 -1
  324. package/lib/cjs/validation/Validators/utils.js.map +0 -1
  325. package/lib/cjs/validation/decorators.js.map +0 -1
  326. package/lib/cjs/validation/index.js.map +0 -1
  327. package/lib/cjs/validation/types.js.map +0 -1
@@ -0,0 +1,47 @@
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?: any, descriptor?: PropertyDescriptor | number) => void;
@@ -0,0 +1,10 @@
1
+ export * from "./constants.cjs";
2
+ export * from "./construction.cjs";
3
+ export * from "./decorators.cjs";
4
+ export * from "./ModelRegistry.cjs";
5
+ export * from "./Model.cjs";
6
+ export * from "./ModelErrorDefinition.cjs";
7
+ export * from "./Builder.cjs";
8
+ export * from "./types.cjs";
9
+ export * from "./validation.cjs";
10
+ export * from "./utils.cjs";
@@ -0,0 +1,10 @@
1
+ export * from "./constants.js";
2
+ export * from "./construction.js";
3
+ export * from "./decorators.js";
4
+ export * from "./ModelRegistry.js";
5
+ export * from "./Model.js";
6
+ export * from "./ModelErrorDefinition.js";
7
+ export * from "./Builder.js";
8
+ export * from "./types.js";
9
+ export * from "./validation.js";
10
+ export * from "./utils.js";
@@ -0,0 +1,145 @@
1
+ import type { ConditionalAsync } from "../types/index.cjs";
2
+ import { ModelErrorDefinition } from "./ModelErrorDefinition.cjs";
3
+ import { Model } from "./Model.cjs";
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
+ }>;
@@ -0,0 +1,145 @@
1
+ import type { ConditionalAsync } from "../types/index.js";
2
+ import { ModelErrorDefinition } from "./ModelErrorDefinition.js";
3
+ import { Model } from "./Model.js";
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
+ }>;
@@ -0,0 +1,13 @@
1
+ import { ConditionalAsync } from "../types/index.cjs";
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>;
@@ -0,0 +1,13 @@
1
+ import { ConditionalAsync } from "../types/index.js";
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>;
@@ -0,0 +1,92 @@
1
+ import { ModelErrorDefinition } from "./ModelErrorDefinition.cjs";
2
+ import type { Model } from "./Model.cjs";
3
+ import { ConditionalAsync } from "../types/index.cjs";
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>;
@@ -0,0 +1,92 @@
1
+ import { ModelErrorDefinition } from "./ModelErrorDefinition.js";
2
+ import type { Model } from "./Model.js";
3
+ import { ConditionalAsync } from "../types/index.js";
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>;