@warlock.js/core 3.0.11 → 3.0.13

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 (380) hide show
  1. package/bin/warlock-loader.mjs +9 -9
  2. package/cjs/application.js +1 -1
  3. package/cjs/application.js.map +1 -1
  4. package/cjs/console/commander.js +1 -1
  5. package/cjs/console/commander.js.map +1 -1
  6. package/cjs/http/UploadedFile.js +3 -3
  7. package/cjs/http/UploadedFile.js.map +1 -1
  8. package/cjs/http/errors/index.d.ts +2 -0
  9. package/cjs/http/errors/index.d.ts.map +1 -0
  10. package/cjs/http/errors/resource-not-found.error.d.ts +13 -0
  11. package/cjs/http/errors/resource-not-found.error.d.ts.map +1 -0
  12. package/cjs/http/errors/resource-not-found.error.js +24 -0
  13. package/cjs/http/errors/resource-not-found.error.js.map +1 -0
  14. package/cjs/http/index.d.ts +1 -0
  15. package/cjs/http/index.d.ts.map +1 -1
  16. package/cjs/http/middleware/_inject-request-context.d.ts.map +1 -1
  17. package/cjs/http/middleware/cache-response-middleware.d.ts.map +1 -1
  18. package/cjs/http/middleware/cache-response-middleware.js +0 -1
  19. package/cjs/http/middleware/cache-response-middleware.js.map +1 -1
  20. package/cjs/http/plugins/index.d.ts +1 -1
  21. package/cjs/http/plugins/index.d.ts.map +1 -1
  22. package/cjs/http/request.d.ts +20 -5
  23. package/cjs/http/request.d.ts.map +1 -1
  24. package/cjs/http/request.js +34 -5
  25. package/cjs/http/request.js.map +1 -1
  26. package/cjs/http/response.d.ts +3 -2
  27. package/cjs/http/response.d.ts.map +1 -1
  28. package/cjs/http/response.js +15 -4
  29. package/cjs/http/response.js.map +1 -1
  30. package/cjs/http/types.d.ts +12 -0
  31. package/cjs/http/types.d.ts.map +1 -1
  32. package/cjs/index.d.ts +2 -0
  33. package/cjs/index.d.ts.map +1 -1
  34. package/cjs/index.js +1 -1
  35. package/cjs/modules/uploads/controllers/upload-files.d.ts.map +1 -1
  36. package/cjs/modules/uploads/controllers/upload-files.js +7 -7
  37. package/cjs/modules/uploads/controllers/upload-files.js.map +1 -1
  38. package/cjs/modules/uploads/output/upload-output.d.ts.map +1 -1
  39. package/cjs/modules/uploads/output/upload-output.js +2 -2
  40. package/cjs/modules/uploads/output/upload-output.js.map +1 -1
  41. package/cjs/modules/uploads/utils/get-watermark-options.js +1 -1
  42. package/cjs/modules/uploads/utils/get-watermark-options.js.map +1 -1
  43. package/cjs/output/output.js +1 -1
  44. package/cjs/output/output.js.map +1 -1
  45. package/cjs/react/index.d.ts +1 -10
  46. package/cjs/react/index.d.ts.map +1 -1
  47. package/cjs/react/index.js +3 -4
  48. package/cjs/react/index.js.map +1 -1
  49. package/cjs/repositories/repository-list-manager.js +1 -1
  50. package/cjs/repositories/repository-list-manager.js.map +1 -1
  51. package/cjs/router/router.d.ts +0 -8
  52. package/cjs/router/router.d.ts.map +1 -1
  53. package/cjs/router/router.js +3 -36
  54. package/cjs/router/router.js.map +1 -1
  55. package/cjs/router/types.d.ts +1 -1
  56. package/cjs/router/types.d.ts.map +1 -1
  57. package/cjs/starters/http-server-starter.d.ts.map +1 -1
  58. package/cjs/starters/http-server-starter.js +7 -2
  59. package/cjs/starters/http-server-starter.js.map +1 -1
  60. package/cjs/starters/start-cli-server.d.ts.map +1 -1
  61. package/cjs/starters/start-cli-server.js +10 -1
  62. package/cjs/starters/start-cli-server.js.map +1 -1
  63. package/cjs/starters/start-http-server.d.ts +3 -2
  64. package/cjs/starters/start-http-server.d.ts.map +1 -1
  65. package/cjs/starters/start-http-server.js +19 -8
  66. package/cjs/starters/start-http-server.js.map +1 -1
  67. package/cjs/utils/date-output.d.ts.map +1 -1
  68. package/cjs/utils/date-output.js +2 -4
  69. package/cjs/utils/date-output.js.map +1 -1
  70. package/cjs/utils/get-localized.d.ts.map +1 -1
  71. package/cjs/utils/get-localized.js.map +1 -1
  72. package/cjs/utils/glob.js +2 -2
  73. package/cjs/utils/glob.js.map +1 -1
  74. package/cjs/v/database/exists-except-current-id.d.ts +7 -0
  75. package/cjs/v/database/exists-except-current-id.d.ts.map +1 -0
  76. package/cjs/v/database/exists-except-current-id.js +23 -0
  77. package/cjs/v/database/exists-except-current-id.js.map +1 -0
  78. package/cjs/v/database/exists-except-current-user.d.ts +7 -0
  79. package/cjs/v/database/exists-except-current-user.d.ts.map +1 -0
  80. package/cjs/v/database/exists-except-current-user.js +25 -0
  81. package/cjs/v/database/exists-except-current-user.js.map +1 -0
  82. package/cjs/v/database/exists.d.ts +7 -0
  83. package/cjs/v/database/exists.d.ts.map +1 -0
  84. package/cjs/v/database/exists.js +21 -0
  85. package/cjs/v/database/exists.js.map +1 -0
  86. package/cjs/v/database/index.d.ts +12 -0
  87. package/cjs/v/database/index.d.ts.map +1 -0
  88. package/cjs/v/database/types.d.ts +68 -0
  89. package/cjs/v/database/types.d.ts.map +1 -0
  90. package/cjs/v/database/unique-except-current-id.d.ts +7 -0
  91. package/cjs/v/database/unique-except-current-id.d.ts.map +1 -0
  92. package/cjs/v/database/unique-except-current-id.js +23 -0
  93. package/cjs/v/database/unique-except-current-id.js.map +1 -0
  94. package/cjs/v/database/unique-except-current-user.d.ts +7 -0
  95. package/cjs/v/database/unique-except-current-user.d.ts.map +1 -0
  96. package/cjs/v/database/unique-except-current-user.js +25 -0
  97. package/cjs/v/database/unique-except-current-user.js.map +1 -0
  98. package/cjs/v/database/unique.d.ts +7 -0
  99. package/cjs/v/database/unique.d.ts.map +1 -0
  100. package/cjs/v/database/unique.js +30 -0
  101. package/cjs/v/database/unique.js.map +1 -0
  102. package/cjs/v/file/file.d.ts +22 -0
  103. package/cjs/v/file/file.d.ts.map +1 -0
  104. package/cjs/v/file/file.js +60 -0
  105. package/cjs/v/file/file.js.map +1 -0
  106. package/cjs/v/file/index.d.ts +6 -0
  107. package/cjs/v/file/index.d.ts.map +1 -0
  108. package/cjs/v/index.d.ts +17 -0
  109. package/cjs/v/index.d.ts.map +1 -0
  110. package/cjs/v/init.d.ts +7 -0
  111. package/cjs/v/init.d.ts.map +1 -0
  112. package/cjs/v/init.js +40 -0
  113. package/cjs/v/init.js.map +1 -0
  114. package/cjs/v/plugins/database-plugin.d.ts +14 -0
  115. package/cjs/v/plugins/database-plugin.d.ts.map +1 -0
  116. package/cjs/v/plugins/database-plugin.js +95 -0
  117. package/cjs/v/plugins/database-plugin.js.map +1 -0
  118. package/cjs/v/plugins/file-plugin.d.ts +11 -0
  119. package/cjs/v/plugins/file-plugin.d.ts.map +1 -0
  120. package/cjs/v/plugins/file-plugin.js +17 -0
  121. package/cjs/v/plugins/file-plugin.js.map +1 -0
  122. package/cjs/v/plugins/index.d.ts +8 -0
  123. package/cjs/v/plugins/index.d.ts.map +1 -0
  124. package/cjs/v/string/index.d.ts +6 -0
  125. package/cjs/v/string/index.d.ts.map +1 -0
  126. package/cjs/v/string/uploadable.d.ts +6 -0
  127. package/cjs/v/string/uploadable.d.ts.map +1 -0
  128. package/cjs/v/string/uploadable.js +14 -0
  129. package/cjs/v/string/uploadable.js.map +1 -0
  130. package/cjs/v/types.d.ts +53 -0
  131. package/cjs/v/types.d.ts.map +1 -0
  132. package/cjs/v/validators/file-validator.d.ts +36 -0
  133. package/cjs/v/validators/file-validator.d.ts.map +1 -0
  134. package/cjs/v/validators/file-validator.js +88 -0
  135. package/cjs/v/validators/file-validator.js.map +1 -0
  136. package/cjs/v/validators/index.d.ts +7 -0
  137. package/cjs/v/validators/index.d.ts.map +1 -0
  138. package/cjs/validator/index.d.ts +0 -1
  139. package/cjs/validator/index.d.ts.map +1 -1
  140. package/cjs/validator/locales.js +518 -10
  141. package/cjs/validator/locales.js.map +1 -1
  142. package/cjs/validator/types.d.ts +28 -0
  143. package/cjs/validator/types.d.ts.map +1 -1
  144. package/cjs/validator/validateAll.d.ts.map +1 -1
  145. package/cjs/validator/validateAll.js +5 -2
  146. package/cjs/validator/validateAll.js.map +1 -1
  147. package/esm/application.js +1 -1
  148. package/esm/application.js.map +1 -1
  149. package/esm/console/commander.js +1 -1
  150. package/esm/console/commander.js.map +1 -1
  151. package/esm/http/errors/index.d.ts +2 -0
  152. package/esm/http/errors/index.d.ts.map +1 -0
  153. package/esm/http/errors/resource-not-found.error.d.ts +13 -0
  154. package/esm/http/errors/resource-not-found.error.d.ts.map +1 -0
  155. package/esm/http/errors/resource-not-found.error.js +24 -0
  156. package/esm/http/errors/resource-not-found.error.js.map +1 -0
  157. package/esm/http/index.d.ts +1 -0
  158. package/esm/http/index.d.ts.map +1 -1
  159. package/esm/http/middleware/_inject-request-context.d.ts.map +1 -1
  160. package/esm/http/middleware/cache-response-middleware.d.ts.map +1 -1
  161. package/esm/http/middleware/cache-response-middleware.js +0 -1
  162. package/esm/http/middleware/cache-response-middleware.js.map +1 -1
  163. package/esm/http/plugins/index.d.ts +1 -1
  164. package/esm/http/plugins/index.d.ts.map +1 -1
  165. package/esm/http/request.d.ts +20 -5
  166. package/esm/http/request.d.ts.map +1 -1
  167. package/esm/http/request.js +34 -5
  168. package/esm/http/request.js.map +1 -1
  169. package/esm/http/response.d.ts +3 -2
  170. package/esm/http/response.d.ts.map +1 -1
  171. package/esm/http/response.js +16 -5
  172. package/esm/http/response.js.map +1 -1
  173. package/esm/http/types.d.ts +12 -0
  174. package/esm/http/types.d.ts.map +1 -1
  175. package/esm/index.d.ts +2 -0
  176. package/esm/index.d.ts.map +1 -1
  177. package/esm/index.js +1 -1
  178. package/esm/modules/uploads/controllers/upload-files.d.ts.map +1 -1
  179. package/esm/modules/uploads/controllers/upload-files.js +2 -2
  180. package/esm/modules/uploads/controllers/upload-files.js.map +1 -1
  181. package/esm/modules/uploads/output/upload-output.d.ts.map +1 -1
  182. package/esm/modules/uploads/output/upload-output.js +2 -2
  183. package/esm/modules/uploads/output/upload-output.js.map +1 -1
  184. package/esm/modules/uploads/utils/get-watermark-options.js +1 -1
  185. package/esm/modules/uploads/utils/get-watermark-options.js.map +1 -1
  186. package/esm/output/output.js +1 -1
  187. package/esm/output/output.js.map +1 -1
  188. package/esm/react/index.d.ts +1 -10
  189. package/esm/react/index.d.ts.map +1 -1
  190. package/esm/react/index.js +2 -3
  191. package/esm/react/index.js.map +1 -1
  192. package/esm/repositories/repository-list-manager.js +1 -1
  193. package/esm/repositories/repository-list-manager.js.map +1 -1
  194. package/esm/router/router.d.ts +0 -8
  195. package/esm/router/router.d.ts.map +1 -1
  196. package/esm/router/router.js +3 -36
  197. package/esm/router/router.js.map +1 -1
  198. package/esm/router/types.d.ts +1 -1
  199. package/esm/router/types.d.ts.map +1 -1
  200. package/esm/starters/http-server-starter.d.ts.map +1 -1
  201. package/esm/starters/http-server-starter.js +7 -2
  202. package/esm/starters/http-server-starter.js.map +1 -1
  203. package/esm/starters/start-cli-server.d.ts.map +1 -1
  204. package/esm/starters/start-cli-server.js +10 -1
  205. package/esm/starters/start-cli-server.js.map +1 -1
  206. package/esm/starters/start-http-server.d.ts +3 -2
  207. package/esm/starters/start-http-server.d.ts.map +1 -1
  208. package/esm/starters/start-http-server.js +19 -8
  209. package/esm/starters/start-http-server.js.map +1 -1
  210. package/esm/utils/date-output.d.ts.map +1 -1
  211. package/esm/utils/date-output.js +2 -4
  212. package/esm/utils/date-output.js.map +1 -1
  213. package/esm/utils/get-localized.d.ts.map +1 -1
  214. package/esm/utils/get-localized.js.map +1 -1
  215. package/esm/v/database/exists-except-current-id.d.ts +7 -0
  216. package/esm/v/database/exists-except-current-id.d.ts.map +1 -0
  217. package/esm/v/database/exists-except-current-id.js +23 -0
  218. package/esm/v/database/exists-except-current-id.js.map +1 -0
  219. package/esm/v/database/exists-except-current-user.d.ts +7 -0
  220. package/esm/v/database/exists-except-current-user.d.ts.map +1 -0
  221. package/esm/v/database/exists-except-current-user.js +25 -0
  222. package/esm/v/database/exists-except-current-user.js.map +1 -0
  223. package/esm/v/database/exists.d.ts +7 -0
  224. package/esm/v/database/exists.d.ts.map +1 -0
  225. package/esm/v/database/exists.js +21 -0
  226. package/esm/v/database/exists.js.map +1 -0
  227. package/esm/v/database/index.d.ts +12 -0
  228. package/esm/v/database/index.d.ts.map +1 -0
  229. package/esm/v/database/types.d.ts +68 -0
  230. package/esm/v/database/types.d.ts.map +1 -0
  231. package/esm/v/database/unique-except-current-id.d.ts +7 -0
  232. package/esm/v/database/unique-except-current-id.d.ts.map +1 -0
  233. package/esm/v/database/unique-except-current-id.js +23 -0
  234. package/esm/v/database/unique-except-current-id.js.map +1 -0
  235. package/esm/v/database/unique-except-current-user.d.ts +7 -0
  236. package/esm/v/database/unique-except-current-user.d.ts.map +1 -0
  237. package/esm/v/database/unique-except-current-user.js +25 -0
  238. package/esm/v/database/unique-except-current-user.js.map +1 -0
  239. package/esm/v/database/unique.d.ts +7 -0
  240. package/esm/v/database/unique.d.ts.map +1 -0
  241. package/esm/v/database/unique.js +30 -0
  242. package/esm/v/database/unique.js.map +1 -0
  243. package/esm/v/file/file.d.ts +22 -0
  244. package/esm/v/file/file.d.ts.map +1 -0
  245. package/esm/v/file/file.js +60 -0
  246. package/esm/v/file/file.js.map +1 -0
  247. package/esm/v/file/index.d.ts +6 -0
  248. package/esm/v/file/index.d.ts.map +1 -0
  249. package/esm/v/index.d.ts +17 -0
  250. package/esm/v/index.d.ts.map +1 -0
  251. package/esm/v/init.d.ts +7 -0
  252. package/esm/v/init.d.ts.map +1 -0
  253. package/esm/v/init.js +40 -0
  254. package/esm/v/init.js.map +1 -0
  255. package/esm/v/plugins/database-plugin.d.ts +14 -0
  256. package/esm/v/plugins/database-plugin.d.ts.map +1 -0
  257. package/esm/v/plugins/database-plugin.js +95 -0
  258. package/esm/v/plugins/database-plugin.js.map +1 -0
  259. package/esm/v/plugins/file-plugin.d.ts +11 -0
  260. package/esm/v/plugins/file-plugin.d.ts.map +1 -0
  261. package/esm/v/plugins/file-plugin.js +17 -0
  262. package/esm/v/plugins/file-plugin.js.map +1 -0
  263. package/esm/v/plugins/index.d.ts +8 -0
  264. package/esm/v/plugins/index.d.ts.map +1 -0
  265. package/esm/v/string/index.d.ts +6 -0
  266. package/esm/v/string/index.d.ts.map +1 -0
  267. package/esm/v/string/uploadable.d.ts +6 -0
  268. package/esm/v/string/uploadable.d.ts.map +1 -0
  269. package/esm/v/string/uploadable.js +14 -0
  270. package/esm/v/string/uploadable.js.map +1 -0
  271. package/esm/v/types.d.ts +53 -0
  272. package/esm/v/types.d.ts.map +1 -0
  273. package/esm/v/validators/file-validator.d.ts +36 -0
  274. package/esm/v/validators/file-validator.d.ts.map +1 -0
  275. package/esm/v/validators/file-validator.js +88 -0
  276. package/esm/v/validators/file-validator.js.map +1 -0
  277. package/esm/v/validators/index.d.ts +7 -0
  278. package/esm/v/validators/index.d.ts.map +1 -0
  279. package/esm/validator/index.d.ts +0 -1
  280. package/esm/validator/index.d.ts.map +1 -1
  281. package/esm/validator/locales.js +518 -10
  282. package/esm/validator/locales.js.map +1 -1
  283. package/esm/validator/types.d.ts +28 -0
  284. package/esm/validator/types.d.ts.map +1 -1
  285. package/esm/validator/validateAll.d.ts.map +1 -1
  286. package/esm/validator/validateAll.js +4 -1
  287. package/esm/validator/validateAll.js.map +1 -1
  288. package/package.json +3 -3
  289. package/cjs/react/page-renderer.d.ts +0 -18
  290. package/cjs/react/page-renderer.d.ts.map +0 -1
  291. package/cjs/react/page-renderer.js +0 -69
  292. package/cjs/react/page-renderer.js.map +0 -1
  293. package/cjs/react/plugin.d.ts +0 -15
  294. package/cjs/react/plugin.d.ts.map +0 -1
  295. package/cjs/react/plugin.js +0 -22
  296. package/cjs/react/plugin.js.map +0 -1
  297. package/cjs/react/vite-config.d.ts +0 -9
  298. package/cjs/react/vite-config.d.ts.map +0 -1
  299. package/cjs/react/vite-config.js +0 -74
  300. package/cjs/react/vite-config.js.map +0 -1
  301. package/cjs/validator/v/array-validator.d.ts +0 -21
  302. package/cjs/validator/v/array-validator.d.ts.map +0 -1
  303. package/cjs/validator/v/base-validator.d.ts +0 -117
  304. package/cjs/validator/v/base-validator.d.ts.map +0 -1
  305. package/cjs/validator/v/database.d.ts +0 -8
  306. package/cjs/validator/v/database.d.ts.map +0 -1
  307. package/cjs/validator/v/database.js +0 -129
  308. package/cjs/validator/v/database.js.map +0 -1
  309. package/cjs/validator/v/index.d.ts +0 -3
  310. package/cjs/validator/v/index.d.ts.map +0 -1
  311. package/cjs/validator/v/mutators.d.ts +0 -24
  312. package/cjs/validator/v/mutators.d.ts.map +0 -1
  313. package/cjs/validator/v/mutators.js +0 -88
  314. package/cjs/validator/v/mutators.js.map +0 -1
  315. package/cjs/validator/v/number-validator.d.ts +0 -21
  316. package/cjs/validator/v/number-validator.d.ts.map +0 -1
  317. package/cjs/validator/v/object-validator.d.ts +0 -37
  318. package/cjs/validator/v/object-validator.d.ts.map +0 -1
  319. package/cjs/validator/v/rules.d.ts +0 -265
  320. package/cjs/validator/v/rules.d.ts.map +0 -1
  321. package/cjs/validator/v/rules.js +0 -914
  322. package/cjs/validator/v/rules.js.map +0 -1
  323. package/cjs/validator/v/schema.d.ts +0 -625
  324. package/cjs/validator/v/schema.d.ts.map +0 -1
  325. package/cjs/validator/v/schema.js +0 -1212
  326. package/cjs/validator/v/schema.js.map +0 -1
  327. package/cjs/validator/v/string-validator.d.ts +0 -41
  328. package/cjs/validator/v/string-validator.d.ts.map +0 -1
  329. package/cjs/validator/v/types.d.ts +0 -180
  330. package/cjs/validator/v/types.d.ts.map +0 -1
  331. package/cjs/validator/v/utils.d.ts +0 -5
  332. package/cjs/validator/v/utils.d.ts.map +0 -1
  333. package/cjs/validator/v/utils.js +0 -29
  334. package/cjs/validator/v/utils.js.map +0 -1
  335. package/esm/react/page-renderer.d.ts +0 -18
  336. package/esm/react/page-renderer.d.ts.map +0 -1
  337. package/esm/react/page-renderer.js +0 -69
  338. package/esm/react/page-renderer.js.map +0 -1
  339. package/esm/react/plugin.d.ts +0 -15
  340. package/esm/react/plugin.d.ts.map +0 -1
  341. package/esm/react/plugin.js +0 -22
  342. package/esm/react/plugin.js.map +0 -1
  343. package/esm/react/vite-config.d.ts +0 -9
  344. package/esm/react/vite-config.d.ts.map +0 -1
  345. package/esm/react/vite-config.js +0 -74
  346. package/esm/react/vite-config.js.map +0 -1
  347. package/esm/validator/v/array-validator.d.ts +0 -21
  348. package/esm/validator/v/array-validator.d.ts.map +0 -1
  349. package/esm/validator/v/base-validator.d.ts +0 -117
  350. package/esm/validator/v/base-validator.d.ts.map +0 -1
  351. package/esm/validator/v/database.d.ts +0 -8
  352. package/esm/validator/v/database.d.ts.map +0 -1
  353. package/esm/validator/v/database.js +0 -129
  354. package/esm/validator/v/database.js.map +0 -1
  355. package/esm/validator/v/index.d.ts +0 -3
  356. package/esm/validator/v/index.d.ts.map +0 -1
  357. package/esm/validator/v/mutators.d.ts +0 -24
  358. package/esm/validator/v/mutators.d.ts.map +0 -1
  359. package/esm/validator/v/mutators.js +0 -88
  360. package/esm/validator/v/mutators.js.map +0 -1
  361. package/esm/validator/v/number-validator.d.ts +0 -21
  362. package/esm/validator/v/number-validator.d.ts.map +0 -1
  363. package/esm/validator/v/object-validator.d.ts +0 -37
  364. package/esm/validator/v/object-validator.d.ts.map +0 -1
  365. package/esm/validator/v/rules.d.ts +0 -265
  366. package/esm/validator/v/rules.d.ts.map +0 -1
  367. package/esm/validator/v/rules.js +0 -914
  368. package/esm/validator/v/rules.js.map +0 -1
  369. package/esm/validator/v/schema.d.ts +0 -625
  370. package/esm/validator/v/schema.d.ts.map +0 -1
  371. package/esm/validator/v/schema.js +0 -1212
  372. package/esm/validator/v/schema.js.map +0 -1
  373. package/esm/validator/v/string-validator.d.ts +0 -41
  374. package/esm/validator/v/string-validator.d.ts.map +0 -1
  375. package/esm/validator/v/types.d.ts +0 -180
  376. package/esm/validator/v/types.d.ts.map +0 -1
  377. package/esm/validator/v/utils.d.ts +0 -5
  378. package/esm/validator/v/utils.d.ts.map +0 -1
  379. package/esm/validator/v/utils.js +0 -29
  380. package/esm/validator/v/utils.js.map +0 -1
@@ -1,914 +0,0 @@
1
- 'use strict';var reinforcements=require('@mongez/reinforcements'),supportiveIs=require('@mongez/supportive-is'),dayjs=require('dayjs'),net=require('net'),UploadedFile=require('../../http/UploadedFile.js'),upload=require('../../modules/uploads/models/upload.js'),utils=require('./utils.js');require('@warlock.js/cascade'),require('../../http/middleware/inject-request-context.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var dayjs__default=/*#__PURE__*/_interopDefault(dayjs);const requiredRule = {
2
- name: "required",
3
- defaultErrorMessage: "The :input is required",
4
- requiresValue: false,
5
- sortOrder: -2,
6
- async validate(value, context) {
7
- if (supportiveIs.isEmpty(value)) {
8
- return utils.invalidRule(this, context);
9
- }
10
- return utils.VALID_RULE;
11
- },
12
- };
13
- const requiredWithRule = {
14
- name: "requiredWith",
15
- description: "The field is required if another field is present",
16
- sortOrder: -2,
17
- requiresValue: false,
18
- defaultErrorMessage: "The :input is required",
19
- async validate(value, context) {
20
- const otherField = this.context.options.field;
21
- const fieldValue = reinforcements.get(context.allValues, otherField);
22
- if ([undefined, null].includes(fieldValue)) {
23
- return utils.VALID_RULE;
24
- }
25
- if (supportiveIs.isEmpty(value)) {
26
- return utils.invalidRule(this, context);
27
- }
28
- return utils.VALID_RULE;
29
- },
30
- };
31
- const requiredIfAbsentRule = {
32
- name: "requiredIfAbsent",
33
- description: "The field is required if another field is absent",
34
- sortOrder: -2,
35
- requiresValue: false,
36
- defaultErrorMessage: "The :input is required",
37
- async validate(value, context) {
38
- const otherField = this.context.options.field;
39
- const fieldValue = reinforcements.get(context.allValues || {}, otherField);
40
- const isPresent = ![undefined, null].includes(fieldValue);
41
- if (!isPresent && supportiveIs.isEmpty(value)) {
42
- return utils.invalidRule(this, context);
43
- }
44
- return utils.VALID_RULE;
45
- },
46
- };
47
- const requiredIfSiblingFieldIsAbsentRule = {
48
- name: "requiredIfSiblingFieldIsAbsent",
49
- description: "The :input is required",
50
- sortOrder: -2,
51
- requiresValue: false,
52
- defaultErrorMessage: ":input field is required",
53
- async validate(value, context) {
54
- const otherField = this.context.options.field;
55
- const otherFieldValue = reinforcements.get(context.parent, otherField);
56
- const isPresent = ![undefined, null].includes(otherFieldValue);
57
- if (!isPresent && supportiveIs.isEmpty(value)) {
58
- return utils.invalidRule(this, context);
59
- }
60
- return utils.VALID_RULE;
61
- },
62
- };
63
- const requiredIfSiblingFieldAllAbsentRule = {
64
- name: "requiredIfSiblingFieldAllAbsent",
65
- description: "The field is required if all other fields are absent",
66
- sortOrder: -2,
67
- requiresValue: false,
68
- defaultErrorMessage: "The :input is required",
69
- async validate(value, context) {
70
- const fields = this.context.options.fields;
71
- let isPresent = false;
72
- for (const field of fields) {
73
- const fieldValue = reinforcements.get(context.parent, field);
74
- if (![undefined, null].includes(fieldValue)) {
75
- isPresent = true;
76
- break;
77
- }
78
- }
79
- if (!isPresent && supportiveIs.isEmpty(value)) {
80
- return utils.invalidRule(this, context);
81
- }
82
- return utils.VALID_RULE;
83
- },
84
- };
85
- const requiredIfEmptyRule = {
86
- name: "requiredIfEmpty",
87
- description: "The field is required if another field is empty",
88
- sortOrder: -2,
89
- requiresValue: false,
90
- defaultErrorMessage: "The :input is required",
91
- async validate(value, context) {
92
- const otherField = this.context.options.field;
93
- const fieldValue = reinforcements.get(context.allValues, otherField);
94
- if (supportiveIs.isEmpty(fieldValue) && supportiveIs.isEmpty(value)) {
95
- return utils.invalidRule(this, context);
96
- }
97
- return utils.VALID_RULE;
98
- },
99
- };
100
- // required if sibling field is empty
101
- const requiredIfSiblingFieldEmptyRule = {
102
- name: "requiredIfSiblingFieldEmpty",
103
- description: "The field is required if another field in same parent context is empty",
104
- sortOrder: -2,
105
- requiresValue: false,
106
- defaultErrorMessage: "The :input is required",
107
- async validate(value, context) {
108
- const otherField = this.context.options.field;
109
- const fieldValue = reinforcements.get(context.parent, otherField);
110
- if (supportiveIs.isEmpty(fieldValue) && supportiveIs.isEmpty(value)) {
111
- return utils.invalidRule(this, context);
112
- }
113
- return utils.VALID_RULE;
114
- },
115
- };
116
- const requiredIfFieldRule = {
117
- name: "requiredIfField",
118
- description: "The field is required if another field has a specific value",
119
- sortOrder: -2,
120
- requiresValue: false,
121
- defaultErrorMessage: "The :input is required",
122
- async validate(value, context) {
123
- const otherField = this.context.options.field;
124
- const otherFieldValue = this.context.options.value;
125
- if (otherField === undefined) {
126
- throw new Error("The field option is required for requiredIfField rule");
127
- }
128
- const fieldValue = reinforcements.get(context.allValues, otherField);
129
- if (fieldValue === otherFieldValue && supportiveIs.isEmpty(value)) {
130
- return utils.invalidRule(this, context);
131
- }
132
- return utils.VALID_RULE;
133
- },
134
- };
135
- const requiredIfSiblingFieldRule = {
136
- name: "requiredIfSiblingField",
137
- description: "The field is required if another field in same parent context has a specific value",
138
- sortOrder: -2,
139
- requiresValue: false,
140
- defaultErrorMessage: "The :input is required",
141
- async validate(value, context) {
142
- const otherField = this.context.options.field;
143
- const otherFieldValue = this.context.options.value;
144
- const parentValues = context.parent;
145
- const fieldValue = reinforcements.get(parentValues, otherField);
146
- if (fieldValue === otherFieldValue && supportiveIs.isEmpty(value)) {
147
- return utils.invalidRule(this, context);
148
- }
149
- return utils.VALID_RULE;
150
- },
151
- };
152
- const requiredUnlessSiblingFieldRule = {
153
- name: "requiredUnlessSiblingField",
154
- description: "The field is required unless another field in same parent context has a specific value",
155
- sortOrder: -2,
156
- requiresValue: false,
157
- defaultErrorMessage: "The :input is required",
158
- async validate(value, context) {
159
- const otherField = this.context.options.field;
160
- const otherFieldValue = this.context.options.value;
161
- const parentValues = context.parent;
162
- const fieldValue = reinforcements.get(parentValues, otherField);
163
- if (fieldValue !== otherFieldValue && supportiveIs.isEmpty(value)) {
164
- return utils.invalidRule(this, context);
165
- }
166
- return utils.VALID_RULE;
167
- },
168
- };
169
- const objectRule = {
170
- name: "object",
171
- defaultErrorMessage: "The :input must be an object",
172
- async validate(value, context) {
173
- if (supportiveIs.isPlainObject(value)) {
174
- return utils.VALID_RULE;
175
- }
176
- return utils.invalidRule(this, context);
177
- },
178
- };
179
- const stringRule = {
180
- name: "string",
181
- defaultErrorMessage: "The :input must be a string",
182
- async validate(value, context) {
183
- if (typeof value === "string") {
184
- return utils.VALID_RULE;
185
- }
186
- return utils.invalidRule(this, context);
187
- },
188
- };
189
- const numberRule = {
190
- name: "number",
191
- defaultErrorMessage: "The :input must be a number",
192
- async validate(value, context) {
193
- if (typeof value === "number") {
194
- return utils.VALID_RULE;
195
- }
196
- return utils.invalidRule(this, context);
197
- },
198
- };
199
- const booleanRule = {
200
- name: "boolean",
201
- defaultErrorMessage: "The :input must be a boolean",
202
- async validate(value, context) {
203
- if (typeof value === "boolean") {
204
- return utils.VALID_RULE;
205
- }
206
- return utils.invalidRule(this, context);
207
- },
208
- };
209
- const intRule = {
210
- name: "int",
211
- defaultErrorMessage: "The :input must be an integer",
212
- async validate(value, context) {
213
- if (Number.isInteger(value)) {
214
- return utils.VALID_RULE;
215
- }
216
- return utils.invalidRule(this, context);
217
- },
218
- };
219
- const floatRule = {
220
- name: "float",
221
- defaultErrorMessage: "The :input must be a float",
222
- async validate(value, context) {
223
- if (Number.isFinite(value) && !Number.isInteger(value)) {
224
- return utils.VALID_RULE;
225
- }
226
- return utils.invalidRule(this, context);
227
- },
228
- };
229
- const inRule = {
230
- name: "in",
231
- defaultErrorMessage: "The :input must be one of the following values: :options",
232
- async validate(value, context) {
233
- if (this.context.options.values.includes(value)) {
234
- return utils.VALID_RULE;
235
- }
236
- return utils.invalidRule(this, context);
237
- },
238
- };
239
- const enumRule = {
240
- name: "enum",
241
- defaultErrorMessage: "The :input must be one of the following values: :options",
242
- async validate(value, context) {
243
- const enumObject = this.context.options.enum;
244
- const enumValues = Object.values(enumObject);
245
- if (enumValues.includes(value)) {
246
- return utils.VALID_RULE;
247
- }
248
- this.context.options.enum = enumValues.join(", ");
249
- return utils.invalidRule(this, context);
250
- },
251
- };
252
- const withoutWhitespaceRule = {
253
- name: "withoutWhitespace",
254
- defaultErrorMessage: "The :input must not contain whitespace",
255
- async validate(value, context) {
256
- if (!/\s/.test(value)) {
257
- return utils.VALID_RULE;
258
- }
259
- return utils.invalidRule(this, context);
260
- },
261
- };
262
- const minWordsRule = {
263
- name: "minWords",
264
- defaultErrorMessage: `The :input must be at least :minWords words`,
265
- async validate(value, context) {
266
- if (String(value || "").split(" ").length >= this.context.options.minWords) {
267
- return utils.VALID_RULE;
268
- }
269
- return utils.invalidRule(this, context);
270
- },
271
- };
272
- const maxWordsRule = {
273
- name: "maxWords",
274
- defaultErrorMessage: `The :input must be at most :maxWords words`,
275
- async validate(value, context) {
276
- if (String(value || "").split(" ").length <= this.context.options.maxWords) {
277
- return utils.VALID_RULE;
278
- }
279
- return utils.invalidRule(this, context);
280
- },
281
- };
282
- const wordsRule = {
283
- name: "words",
284
- defaultErrorMessage: `The :input must be exactly :words words`,
285
- async validate(value, context) {
286
- if (String(value || "").split(" ").length === this.context.options.words) {
287
- return utils.VALID_RULE;
288
- }
289
- return utils.invalidRule(this, context);
290
- },
291
- };
292
- const minLengthRule = {
293
- name: "minLength",
294
- defaultErrorMessage: `The :input must be at least :minLength characters long`,
295
- async validate(value, context) {
296
- if (String(value || "").length >= this.context.options.minLength) {
297
- return utils.VALID_RULE;
298
- }
299
- return utils.invalidRule(this, context);
300
- },
301
- };
302
- const maxLengthRule = {
303
- name: "maxLength",
304
- defaultErrorMessage: `The :input must not exceed :maxLength characters`,
305
- async validate(value, context) {
306
- if (String(value || "").length <= this.context.options.maxLength) {
307
- return utils.VALID_RULE;
308
- }
309
- return utils.invalidRule(this, context);
310
- },
311
- };
312
- const lengthRule = {
313
- name: "length",
314
- defaultErrorMessage: `The :input must be exactly :length characters long`,
315
- async validate(value, context) {
316
- if (String(value || "").length === this.context.options.length) {
317
- return utils.VALID_RULE;
318
- }
319
- return utils.invalidRule(this, context);
320
- },
321
- };
322
- const minRule = {
323
- name: "min",
324
- defaultErrorMessage: `The :input must be at least :min`,
325
- async validate(value, context) {
326
- if (value >= this.context.options.min) {
327
- return utils.VALID_RULE;
328
- }
329
- return utils.invalidRule(this, context);
330
- },
331
- };
332
- const maxRule = {
333
- name: "max",
334
- defaultErrorMessage: `The :input must equal to or less than :max`,
335
- async validate(value, context) {
336
- if (value <= this.context.options.max) {
337
- return utils.VALID_RULE;
338
- }
339
- return utils.invalidRule(this, context);
340
- },
341
- };
342
- const equalRule = {
343
- name: "equal",
344
- defaultErrorMessage: `The :input must be equal to :value`,
345
- async validate(input, context) {
346
- if (input === this.context.options.value) {
347
- return utils.VALID_RULE;
348
- }
349
- return utils.invalidRule(this, context);
350
- },
351
- };
352
- const emailRule = {
353
- name: "email",
354
- defaultErrorMessage: "The :input must be a valid email address",
355
- async validate(value, context) {
356
- if (supportiveIs.isEmail(value)) {
357
- return utils.VALID_RULE;
358
- }
359
- return utils.invalidRule(this, context);
360
- },
361
- };
362
- const scalarRule = {
363
- name: "scalar",
364
- defaultErrorMessage: "The :input must be a scalar value",
365
- async validate(value, context) {
366
- // a valid value considered to beb either a string, number, or boolean
367
- if (["string", "number", "boolean"].includes(typeof value)) {
368
- return utils.VALID_RULE;
369
- }
370
- return utils.invalidRule(this, context);
371
- },
372
- };
373
- const unknownKeyRule = {
374
- name: "unknownKey",
375
- sortOrder: -1,
376
- defaultErrorMessage: "The :input contains unknown properties",
377
- async validate(value, context) {
378
- const schema = this.context.options.schema;
379
- const allowedKeys = this.context.options.allowedKeys || [];
380
- for (const key in value) {
381
- if (!schema[key] && !allowedKeys.includes(key)) {
382
- this.context.options.key = utils.setKeyPath(context.path, key);
383
- const newContext = {
384
- ...context,
385
- key,
386
- path: utils.setKeyPath(context.path, key),
387
- };
388
- return utils.invalidRule(this, newContext);
389
- }
390
- }
391
- return utils.VALID_RULE;
392
- },
393
- };
394
- const matchesRule = {
395
- name: "matches",
396
- defaultErrorMessage: "The :input must match the :field",
397
- async validate(value, context) {
398
- const otherField = this.context.options.field;
399
- if (value === reinforcements.get(context.allValues, otherField)) {
400
- return utils.VALID_RULE;
401
- }
402
- return utils.invalidRule(this, context);
403
- },
404
- };
405
- const dateRule = {
406
- name: "date",
407
- defaultErrorMessage: "The :input must be a valid date",
408
- async validate(value, context) {
409
- const format = this.context.options.format;
410
- // use dayjs for date validation
411
- if (format) {
412
- const date = dayjs__default.default(value, format);
413
- if (date.isValid()) {
414
- return utils.VALID_RULE;
415
- }
416
- return utils.invalidRule(this, context);
417
- }
418
- if (new Date(value).toString() !== "Invalid Date") {
419
- return utils.VALID_RULE;
420
- }
421
- return utils.invalidRule(this, context);
422
- },
423
- };
424
- // Must be used with Date mutator
425
- const minDateRule = {
426
- name: "minDate",
427
- description: "The field must be at least the given date",
428
- defaultErrorMessage: `The :input must be at least :minDate`,
429
- async validate(value, context) {
430
- if (value >= this.context.options.minDate) {
431
- return utils.VALID_RULE;
432
- }
433
- return utils.invalidRule(this, context);
434
- },
435
- };
436
- // Must be used with Date mutator
437
- const maxDateRule = {
438
- name: "maxDate",
439
- defaultErrorMessage: `The :input must be at most :maxDate`,
440
- async validate(value, context) {
441
- if (value <= this.context.options.maxDate) {
442
- return utils.VALID_RULE;
443
- }
444
- return utils.invalidRule(this, context);
445
- },
446
- };
447
- const urlRule = {
448
- name: "url",
449
- defaultErrorMessage: "The :input must be a valid URL",
450
- async validate(value, context) {
451
- try {
452
- new URL(value);
453
- return utils.VALID_RULE;
454
- }
455
- catch (error) {
456
- return utils.invalidRule(this, context);
457
- }
458
- },
459
- };
460
- const ipRule = {
461
- name: "ip",
462
- defaultErrorMessage: "The :input must be a valid IP address",
463
- async validate(value, context) {
464
- const result = net.isIP(value);
465
- if (result !== 0) {
466
- return utils.VALID_RULE;
467
- }
468
- return utils.invalidRule(this, context);
469
- },
470
- };
471
- const ip4Rule = {
472
- name: "ip4",
473
- defaultErrorMessage: "The :input must be a valid IPv4 address",
474
- async validate(value, context) {
475
- const result = net.isIP(value);
476
- if (result === 4) {
477
- return utils.VALID_RULE;
478
- }
479
- return utils.invalidRule(this, context);
480
- },
481
- };
482
- const ip6Rule = {
483
- name: "ip6",
484
- defaultErrorMessage: "The :input must be a valid IPv6 address",
485
- async validate(value, context) {
486
- const result = net.isIP(value);
487
- if (result === 6) {
488
- return utils.VALID_RULE;
489
- }
490
- return utils.invalidRule(this, context);
491
- },
492
- };
493
- const isNumericRule = {
494
- name: "isNumeric",
495
- defaultErrorMessage: "The :input must be a numeric value",
496
- async validate(value, context) {
497
- if (supportiveIs.isNumeric(value)) {
498
- return utils.VALID_RULE;
499
- }
500
- return utils.invalidRule(this, context);
501
- },
502
- };
503
- const startsWithRule = {
504
- name: "startsWith",
505
- defaultErrorMessage: "The :input must start with :value",
506
- async validate(value, context) {
507
- if (value.startsWith(this.context.options.value)) {
508
- return utils.VALID_RULE;
509
- }
510
- return utils.invalidRule(this, context);
511
- },
512
- };
513
- const endsWithRule = {
514
- name: "endsWith",
515
- defaultErrorMessage: "The :input must end with :value",
516
- async validate(value, context) {
517
- if (value.endsWith(this.context.options.value)) {
518
- return utils.VALID_RULE;
519
- }
520
- return utils.invalidRule(this, context);
521
- },
522
- };
523
- const containsRule = {
524
- name: "contains",
525
- defaultErrorMessage: "The :input must contain :value",
526
- async validate(value, context) {
527
- if (value.includes(this.context.options.value)) {
528
- return utils.VALID_RULE;
529
- }
530
- return utils.invalidRule(this, context);
531
- },
532
- };
533
- const notContainsRule = {
534
- name: "notContains",
535
- defaultErrorMessage: "The :input must not contain :value",
536
- async validate(value, context) {
537
- if (!value.includes(this.context.options.value)) {
538
- return utils.VALID_RULE;
539
- }
540
- return utils.invalidRule(this, context);
541
- },
542
- };
543
- const alphaRule = {
544
- name: "alpha",
545
- defaultErrorMessage: "The :input must contain only alphabetic characters",
546
- async validate(value, context) {
547
- if (/^[a-zA-Z]+$/.test(value)) {
548
- return utils.VALID_RULE;
549
- }
550
- return utils.invalidRule(this, context);
551
- },
552
- };
553
- const alphaNumericRule = {
554
- name: "alphaNumeric",
555
- errorMessage: "The :input must contain only alphabetic and numeric characters",
556
- async validate(value, context) {
557
- if (/^[a-zA-Z0-9]+$/.test(value)) {
558
- return utils.VALID_RULE;
559
- }
560
- return utils.invalidRule(this, context);
561
- },
562
- };
563
- const patternRule = {
564
- name: "pattern",
565
- defaultErrorMessage: "The :input does not match the pattern",
566
- async validate(value, context) {
567
- if (this.context.options.pattern.test(value)) {
568
- return utils.VALID_RULE;
569
- }
570
- return utils.invalidRule(this, context);
571
- },
572
- };
573
- const moduloRule = {
574
- name: "modulo",
575
- defaultErrorMessage: "The :input must be a multiple of :value",
576
- async validate(value, context) {
577
- if (value % this.context.options.value === 0) {
578
- return utils.VALID_RULE;
579
- }
580
- return utils.invalidRule(this, context);
581
- },
582
- };
583
- const isCreditCardRule = {
584
- name: "isCreditCard",
585
- description: "The field must be a valid credit card number",
586
- defaultErrorMessage: "The :input must be a valid credit card number",
587
- async validate(value, context) {
588
- // Luhn algorithm
589
- const cardNumber = value.toString().replace(/\D/g, "");
590
- let sum = 0;
591
- let isEven = false;
592
- for (let i = cardNumber.length - 1; i >= 0; i--) {
593
- let digit = parseInt(cardNumber[i]);
594
- if (isEven) {
595
- digit *= 2;
596
- if (digit > 9) {
597
- digit -= 9;
598
- }
599
- }
600
- sum += digit;
601
- isEven = !isEven;
602
- }
603
- if (sum % 10 === 0) {
604
- return utils.VALID_RULE;
605
- }
606
- return utils.invalidRule(this, context);
607
- },
608
- };
609
- const positiveRule = {
610
- name: "positive",
611
- defaultErrorMessage: "The :input must be a positive number",
612
- async validate(value, context) {
613
- if (value > 0) {
614
- return utils.VALID_RULE;
615
- }
616
- return utils.invalidRule(this, context);
617
- },
618
- };
619
- // unique for array
620
- const uniqueArrayRule = {
621
- name: "uniqueArray",
622
- description: "The array must contain unique values",
623
- defaultErrorMessage: "The :input must contain unique values",
624
- async validate(value, context) {
625
- const uniqueValues = new Set(value);
626
- if (uniqueValues.size === value.length) {
627
- return utils.VALID_RULE;
628
- }
629
- return utils.invalidRule(this, context);
630
- },
631
- };
632
- const uploadableRule = {
633
- name: "uploadable",
634
- defaultErrorMessage: "The :input must be a valid uploadable hash id",
635
- async validate(value, context) {
636
- const hashExists = await upload.Upload.aggregate().where("hash", value).exists();
637
- if (hashExists) {
638
- return utils.VALID_RULE;
639
- }
640
- return utils.invalidRule(this, context);
641
- },
642
- };
643
- const fileRule = {
644
- name: "file",
645
- defaultErrorMessage: "The :input must be a file",
646
- async validate(value, context) {
647
- if (value instanceof UploadedFile.UploadedFile) {
648
- return utils.VALID_RULE;
649
- }
650
- return utils.invalidRule(this, context);
651
- },
652
- };
653
- const fileTypeRule = {
654
- name: "fileType",
655
- defaultErrorMessage: "The :input must be a :types file",
656
- async validate(value, context) {
657
- let mimeTypes = this.context.options.mimeTypes;
658
- if (typeof mimeTypes === "string") {
659
- mimeTypes = [mimeTypes];
660
- }
661
- if (mimeTypes.includes(value.mimeType)) {
662
- return utils.VALID_RULE;
663
- }
664
- return utils.invalidRule(this, context);
665
- },
666
- };
667
- const fileExtensionRule = {
668
- name: "fileExtension",
669
- errorMessage: "The :input must have one of the following extensions: :extensions",
670
- async validate(value, context) {
671
- let extensions = this.context.options.extensions;
672
- if (typeof extensions === "string") {
673
- extensions = [extensions];
674
- }
675
- if (extensions.includes(value.extension)) {
676
- return utils.VALID_RULE;
677
- }
678
- return utils.invalidRule(this, context);
679
- },
680
- };
681
- const maxFileSizeRule = {
682
- name: "maxFileSize",
683
- defaultErrorMessage: "The :input must not exceed :maxFileSize",
684
- async validate(value, context) {
685
- if (value.size <= this.context.options.maxFileSize) {
686
- return utils.VALID_RULE;
687
- }
688
- return utils.invalidRule(this, context);
689
- },
690
- };
691
- const minFileSizeRule = {
692
- name: "minFileSize",
693
- defaultErrorMessage: "The :input must be at least :minFileSize",
694
- async validate(value, context) {
695
- if (value.size >= this.context.options.minFileSize) {
696
- return utils.VALID_RULE;
697
- }
698
- return utils.invalidRule(this, context);
699
- },
700
- };
701
- const imageRule = {
702
- name: "image",
703
- defaultErrorMessage: "The :input must be an image",
704
- async validate(value, context) {
705
- if (value instanceof UploadedFile.UploadedFile && value.isImage) {
706
- return utils.VALID_RULE;
707
- }
708
- return utils.invalidRule(this, context);
709
- },
710
- };
711
- const minWidthRule = {
712
- name: "minWidth",
713
- defaultErrorMessage: "The :input must be at least :minWidth pixels wide",
714
- async validate(value, context) {
715
- const dimensions = await value.dimensions();
716
- if (dimensions.width >= this.context.options.minWidth) {
717
- return utils.VALID_RULE;
718
- }
719
- return utils.invalidRule(this, context);
720
- },
721
- };
722
- const maxWidthRule = {
723
- name: "maxWidth",
724
- defaultErrorMessage: "The :input must be at most :maxWidth pixels wide",
725
- async validate(value, context) {
726
- const dimensions = await value.dimensions();
727
- if (dimensions.width <= this.context.options.maxWidth) {
728
- return utils.VALID_RULE;
729
- }
730
- return utils.invalidRule(this, context);
731
- },
732
- };
733
- const minHeightRule = {
734
- name: "minHeight",
735
- defaultErrorMessage: "The :input must be at least :minHeight pixels tall",
736
- async validate(value, context) {
737
- const dimensions = await value.dimensions();
738
- if (dimensions.height >= this.context.options.minHeight) {
739
- return utils.VALID_RULE;
740
- }
741
- return utils.invalidRule(this, context);
742
- },
743
- };
744
- const maxHeightRule = {
745
- name: "maxHeight",
746
- defaultErrorMessage: "The :input must be at most :maxHeight pixels tall",
747
- async validate(value, context) {
748
- const dimensions = await value.dimensions();
749
- if (dimensions.height <= this.context.options.maxHeight) {
750
- return utils.VALID_RULE;
751
- }
752
- return utils.invalidRule(this, context);
753
- },
754
- };
755
- /**
756
- * Check if the value is one of the allowed values
757
- */
758
- const allowedValuesRule = {
759
- name: "arrayOfValues",
760
- errorMessage: "The :input must be an array containing only the allowed values: :allowedValues",
761
- async validate(value, context) {
762
- const allowedValues = this.context.options.allowedValues;
763
- // Check if the value is an array
764
- if (!Array.isArray(value)) {
765
- return utils.invalidRule(this, context);
766
- }
767
- // Check if all elements in the array are allowed values
768
- const isValid = value.every(item => allowedValues.includes(item));
769
- if (isValid) {
770
- return utils.VALID_RULE;
771
- }
772
- return utils.invalidRule(this, context);
773
- },
774
- };
775
- /**
776
- * Value must not be any of the given values
777
- */
778
- const notAllowedValuesRule = {
779
- name: "notAllowedValues",
780
- errorMessage: "The :input must not be any of the following values: :notAllowedValues",
781
- async validate(value, context) {
782
- const notAllowedValues = this.context.options.notAllowedValues;
783
- if (!notAllowedValues.includes(value)) {
784
- return utils.VALID_RULE;
785
- }
786
- return utils.invalidRule(this, context);
787
- },
788
- };
789
- // Array rules
790
- const arrayRule = {
791
- name: "array",
792
- defaultErrorMessage: "The :input must be an array",
793
- async validate(value, context) {
794
- if (Array.isArray(value)) {
795
- return utils.VALID_RULE;
796
- }
797
- return utils.invalidRule(this, context);
798
- },
799
- };
800
- // End of Array rules
801
- // Color rules
802
- const colorValidationRegex = {
803
- hex: /^#([0-9a-f]{3}){1,2}$/i,
804
- rgb: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
805
- rgba: /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(0?\.\d+)\)$/,
806
- hsl: /^hsl\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
807
- light: /^#([0-9a-f]{3}){1,2}$/i,
808
- dark: /^#([0-9a-f]{3}){1,2}$/i,
809
- };
810
- const rgbColorRule = {
811
- name: "rgbColor",
812
- defaultErrorMessage: "The :input must be a valid RGB color",
813
- async validate(value, context) {
814
- if (value.match(colorValidationRegex.rgb)) {
815
- return utils.VALID_RULE;
816
- }
817
- return utils.invalidRule(this, context);
818
- },
819
- };
820
- const rgbaColorRule = {
821
- name: "rgbaColor",
822
- defaultErrorMessage: "The :input must be a valid RGBA color",
823
- async validate(value, context) {
824
- if (value.match(colorValidationRegex.rgba)) {
825
- return utils.VALID_RULE;
826
- }
827
- return utils.invalidRule(this, context);
828
- },
829
- };
830
- const hexColorRule = {
831
- name: "hexColor",
832
- defaultErrorMessage: "The :input must be a valid hex color",
833
- async validate(value, context) {
834
- if (value.match(colorValidationRegex.hex)) {
835
- return utils.VALID_RULE;
836
- }
837
- return utils.invalidRule(this, context);
838
- },
839
- };
840
- const hslColorRule = {
841
- name: "hslColor",
842
- defaultErrorMessage: "The :input must be a valid HSL color",
843
- async validate(value, context) {
844
- if (value.match(colorValidationRegex.hsl)) {
845
- return utils.VALID_RULE;
846
- }
847
- return utils.invalidRule(this, context);
848
- },
849
- };
850
- const lightColorRule = {
851
- name: "lightColor",
852
- defaultErrorMessage: "The :input must be a light color",
853
- async validate(value, context) {
854
- if (value.match(colorValidationRegex.light)) {
855
- return utils.VALID_RULE;
856
- }
857
- return utils.invalidRule(this, context);
858
- },
859
- };
860
- const darkColorRule = {
861
- name: "darkColor",
862
- defaultErrorMessage: "The :input must be a dark color",
863
- async validate(value, context) {
864
- if (value.match(colorValidationRegex.dark)) {
865
- return utils.VALID_RULE;
866
- }
867
- return utils.invalidRule(this, context);
868
- },
869
- };
870
- const colorRule = {
871
- name: "color",
872
- defaultErrorMessage: "The :input must be a valid color",
873
- async validate(value, context) {
874
- if (value.match(colorValidationRegex.hex) ||
875
- value.match(colorValidationRegex.rgb) ||
876
- value.match(colorValidationRegex.rgba) ||
877
- value.match(colorValidationRegex.hsl)) {
878
- return utils.VALID_RULE;
879
- }
880
- return utils.invalidRule(this, context);
881
- },
882
- };
883
- const forbiddenRule = {
884
- name: "forbidden",
885
- defaultErrorMessage: "The :input is forbidden",
886
- async validate(_value, context) {
887
- return utils.invalidRule(this, context);
888
- },
889
- };
890
- /**
891
- * When rule applies a condition validation rule based on another field value
892
- */
893
- const whenRule = {
894
- name: "when",
895
- description: "Apply conditional validation rules based on another field value",
896
- async validate(value, context) {
897
- const { field, is, otherwise, local } = this.context.options;
898
- const parent = local ? context.parent : context.allValues;
899
- const fieldValue = reinforcements.get(parent, field);
900
- const condition = is[fieldValue] || otherwise;
901
- if (condition) {
902
- const result = await condition.validate(value, context);
903
- if (!result.isValid) {
904
- return {
905
- isValid: false,
906
- error: result.errors[0].error,
907
- input: result.errors[0].input,
908
- path: context.path,
909
- };
910
- }
911
- }
912
- return utils.VALID_RULE;
913
- },
914
- };exports.allowedValuesRule=allowedValuesRule;exports.alphaNumericRule=alphaNumericRule;exports.alphaRule=alphaRule;exports.arrayRule=arrayRule;exports.booleanRule=booleanRule;exports.colorRule=colorRule;exports.containsRule=containsRule;exports.darkColorRule=darkColorRule;exports.dateRule=dateRule;exports.emailRule=emailRule;exports.endsWithRule=endsWithRule;exports.enumRule=enumRule;exports.equalRule=equalRule;exports.fileExtensionRule=fileExtensionRule;exports.fileRule=fileRule;exports.fileTypeRule=fileTypeRule;exports.floatRule=floatRule;exports.forbiddenRule=forbiddenRule;exports.hexColorRule=hexColorRule;exports.hslColorRule=hslColorRule;exports.imageRule=imageRule;exports.inRule=inRule;exports.intRule=intRule;exports.ip4Rule=ip4Rule;exports.ip6Rule=ip6Rule;exports.ipRule=ipRule;exports.isCreditCardRule=isCreditCardRule;exports.isNumericRule=isNumericRule;exports.lengthRule=lengthRule;exports.lightColorRule=lightColorRule;exports.matchesRule=matchesRule;exports.maxDateRule=maxDateRule;exports.maxFileSizeRule=maxFileSizeRule;exports.maxHeightRule=maxHeightRule;exports.maxLengthRule=maxLengthRule;exports.maxRule=maxRule;exports.maxWidthRule=maxWidthRule;exports.maxWordsRule=maxWordsRule;exports.minDateRule=minDateRule;exports.minFileSizeRule=minFileSizeRule;exports.minHeightRule=minHeightRule;exports.minLengthRule=minLengthRule;exports.minRule=minRule;exports.minWidthRule=minWidthRule;exports.minWordsRule=minWordsRule;exports.moduloRule=moduloRule;exports.notAllowedValuesRule=notAllowedValuesRule;exports.notContainsRule=notContainsRule;exports.numberRule=numberRule;exports.objectRule=objectRule;exports.patternRule=patternRule;exports.positiveRule=positiveRule;exports.requiredIfAbsentRule=requiredIfAbsentRule;exports.requiredIfEmptyRule=requiredIfEmptyRule;exports.requiredIfFieldRule=requiredIfFieldRule;exports.requiredIfSiblingFieldAllAbsentRule=requiredIfSiblingFieldAllAbsentRule;exports.requiredIfSiblingFieldEmptyRule=requiredIfSiblingFieldEmptyRule;exports.requiredIfSiblingFieldIsAbsentRule=requiredIfSiblingFieldIsAbsentRule;exports.requiredIfSiblingFieldRule=requiredIfSiblingFieldRule;exports.requiredRule=requiredRule;exports.requiredUnlessSiblingFieldRule=requiredUnlessSiblingFieldRule;exports.requiredWithRule=requiredWithRule;exports.rgbColorRule=rgbColorRule;exports.rgbaColorRule=rgbaColorRule;exports.scalarRule=scalarRule;exports.startsWithRule=startsWithRule;exports.stringRule=stringRule;exports.uniqueArrayRule=uniqueArrayRule;exports.unknownKeyRule=unknownKeyRule;exports.uploadableRule=uploadableRule;exports.urlRule=urlRule;exports.whenRule=whenRule;exports.withoutWhitespaceRule=withoutWhitespaceRule;exports.wordsRule=wordsRule;//# sourceMappingURL=rules.js.map