dino-validation 0.3.0 → 1.0.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 (349) hide show
  1. package/README.md +123 -1687
  2. package/THIRD_PARTY_NOTICES.md +69 -0
  3. package/dist/dv.esm.js +770 -105
  4. package/dist/dv.esm.js.map +1 -1
  5. package/dist/dv.js +770 -104
  6. package/dist/dv.js.map +1 -1
  7. package/dist/dv.min.js +2 -2
  8. package/dist/dv.min.js.map +1 -1
  9. package/dist/dv.unobtrusive.esm.js +428 -0
  10. package/dist/dv.unobtrusive.esm.js.map +1 -0
  11. package/dist/dv.unobtrusive.js +440 -0
  12. package/dist/dv.unobtrusive.js.map +1 -0
  13. package/dist/dv.unobtrusive.min.js +15 -0
  14. package/dist/dv.unobtrusive.min.js.map +1 -0
  15. package/dist/localization/messages_ar.esm.js +2 -2
  16. package/dist/localization/messages_ar.js +3 -3
  17. package/dist/localization/messages_ar.js.map +1 -1
  18. package/dist/localization/messages_ar.min.js +2 -2
  19. package/dist/localization/messages_ar.min.js.map +1 -1
  20. package/dist/localization/messages_az.esm.js +2 -2
  21. package/dist/localization/messages_az.js +3 -3
  22. package/dist/localization/messages_az.js.map +1 -1
  23. package/dist/localization/messages_az.min.js +2 -2
  24. package/dist/localization/messages_az.min.js.map +1 -1
  25. package/dist/localization/messages_bg.esm.js +2 -2
  26. package/dist/localization/messages_bg.js +3 -3
  27. package/dist/localization/messages_bg.js.map +1 -1
  28. package/dist/localization/messages_bg.min.js +2 -2
  29. package/dist/localization/messages_bg.min.js.map +1 -1
  30. package/dist/localization/messages_bn_BD.esm.js +2 -2
  31. package/dist/localization/messages_bn_BD.js +3 -3
  32. package/dist/localization/messages_bn_BD.js.map +1 -1
  33. package/dist/localization/messages_bn_BD.min.js +2 -2
  34. package/dist/localization/messages_bn_BD.min.js.map +1 -1
  35. package/dist/localization/messages_ca.esm.js +2 -2
  36. package/dist/localization/messages_ca.js +3 -3
  37. package/dist/localization/messages_ca.js.map +1 -1
  38. package/dist/localization/messages_ca.min.js +2 -2
  39. package/dist/localization/messages_ca.min.js.map +1 -1
  40. package/dist/localization/messages_cs.esm.js +2 -2
  41. package/dist/localization/messages_cs.js +3 -3
  42. package/dist/localization/messages_cs.js.map +1 -1
  43. package/dist/localization/messages_cs.min.js +2 -2
  44. package/dist/localization/messages_cs.min.js.map +1 -1
  45. package/dist/localization/messages_da.esm.js +2 -2
  46. package/dist/localization/messages_da.js +3 -3
  47. package/dist/localization/messages_da.js.map +1 -1
  48. package/dist/localization/messages_da.min.js +2 -2
  49. package/dist/localization/messages_da.min.js.map +1 -1
  50. package/dist/localization/messages_de.esm.js +2 -2
  51. package/dist/localization/messages_de.js +3 -3
  52. package/dist/localization/messages_de.js.map +1 -1
  53. package/dist/localization/messages_de.min.js +2 -2
  54. package/dist/localization/messages_de.min.js.map +1 -1
  55. package/dist/localization/messages_el.esm.js +2 -2
  56. package/dist/localization/messages_el.js +3 -3
  57. package/dist/localization/messages_el.js.map +1 -1
  58. package/dist/localization/messages_el.min.js +2 -2
  59. package/dist/localization/messages_el.min.js.map +1 -1
  60. package/dist/localization/messages_es.esm.js +2 -2
  61. package/dist/localization/messages_es.js +3 -3
  62. package/dist/localization/messages_es.js.map +1 -1
  63. package/dist/localization/messages_es.min.js +2 -2
  64. package/dist/localization/messages_es.min.js.map +1 -1
  65. package/dist/localization/messages_es_AR.esm.js +2 -2
  66. package/dist/localization/messages_es_AR.js +3 -3
  67. package/dist/localization/messages_es_AR.js.map +1 -1
  68. package/dist/localization/messages_es_AR.min.js +2 -2
  69. package/dist/localization/messages_es_AR.min.js.map +1 -1
  70. package/dist/localization/messages_es_PE.esm.js +2 -2
  71. package/dist/localization/messages_es_PE.js +3 -3
  72. package/dist/localization/messages_es_PE.js.map +1 -1
  73. package/dist/localization/messages_es_PE.min.js +2 -2
  74. package/dist/localization/messages_es_PE.min.js.map +1 -1
  75. package/dist/localization/messages_et.esm.js +2 -2
  76. package/dist/localization/messages_et.js +3 -3
  77. package/dist/localization/messages_et.js.map +1 -1
  78. package/dist/localization/messages_et.min.js +2 -2
  79. package/dist/localization/messages_et.min.js.map +1 -1
  80. package/dist/localization/messages_eu.esm.js +2 -2
  81. package/dist/localization/messages_eu.js +3 -3
  82. package/dist/localization/messages_eu.js.map +1 -1
  83. package/dist/localization/messages_eu.min.js +2 -2
  84. package/dist/localization/messages_eu.min.js.map +1 -1
  85. package/dist/localization/messages_fa.esm.js +2 -2
  86. package/dist/localization/messages_fa.js +3 -3
  87. package/dist/localization/messages_fa.js.map +1 -1
  88. package/dist/localization/messages_fa.min.js +2 -2
  89. package/dist/localization/messages_fa.min.js.map +1 -1
  90. package/dist/localization/messages_fi.esm.js +2 -2
  91. package/dist/localization/messages_fi.js +3 -3
  92. package/dist/localization/messages_fi.js.map +1 -1
  93. package/dist/localization/messages_fi.min.js +2 -2
  94. package/dist/localization/messages_fi.min.js.map +1 -1
  95. package/dist/localization/messages_fr.esm.js +2 -2
  96. package/dist/localization/messages_fr.js +3 -3
  97. package/dist/localization/messages_fr.js.map +1 -1
  98. package/dist/localization/messages_fr.min.js +2 -2
  99. package/dist/localization/messages_fr.min.js.map +1 -1
  100. package/dist/localization/messages_ge.esm.js +2 -2
  101. package/dist/localization/messages_ge.js +3 -3
  102. package/dist/localization/messages_ge.js.map +1 -1
  103. package/dist/localization/messages_ge.min.js +2 -2
  104. package/dist/localization/messages_ge.min.js.map +1 -1
  105. package/dist/localization/messages_gl.esm.js +2 -2
  106. package/dist/localization/messages_gl.js +3 -3
  107. package/dist/localization/messages_gl.js.map +1 -1
  108. package/dist/localization/messages_gl.min.js +2 -2
  109. package/dist/localization/messages_gl.min.js.map +1 -1
  110. package/dist/localization/messages_he.esm.js +2 -2
  111. package/dist/localization/messages_he.js +3 -3
  112. package/dist/localization/messages_he.js.map +1 -1
  113. package/dist/localization/messages_he.min.js +2 -2
  114. package/dist/localization/messages_he.min.js.map +1 -1
  115. package/dist/localization/messages_hi.esm.js +2 -2
  116. package/dist/localization/messages_hi.js +3 -3
  117. package/dist/localization/messages_hi.js.map +1 -1
  118. package/dist/localization/messages_hi.min.js +2 -2
  119. package/dist/localization/messages_hi.min.js.map +1 -1
  120. package/dist/localization/messages_hr.esm.js +2 -2
  121. package/dist/localization/messages_hr.js +3 -3
  122. package/dist/localization/messages_hr.js.map +1 -1
  123. package/dist/localization/messages_hr.min.js +2 -2
  124. package/dist/localization/messages_hr.min.js.map +1 -1
  125. package/dist/localization/messages_hu.esm.js +2 -2
  126. package/dist/localization/messages_hu.js +3 -3
  127. package/dist/localization/messages_hu.js.map +1 -1
  128. package/dist/localization/messages_hu.min.js +2 -2
  129. package/dist/localization/messages_hu.min.js.map +1 -1
  130. package/dist/localization/messages_hy_AM.esm.js +2 -2
  131. package/dist/localization/messages_hy_AM.js +3 -3
  132. package/dist/localization/messages_hy_AM.js.map +1 -1
  133. package/dist/localization/messages_hy_AM.min.js +2 -2
  134. package/dist/localization/messages_hy_AM.min.js.map +1 -1
  135. package/dist/localization/messages_id.esm.js +2 -2
  136. package/dist/localization/messages_id.js +3 -3
  137. package/dist/localization/messages_id.js.map +1 -1
  138. package/dist/localization/messages_id.min.js +2 -2
  139. package/dist/localization/messages_id.min.js.map +1 -1
  140. package/dist/localization/messages_is.esm.js +2 -2
  141. package/dist/localization/messages_is.js +3 -3
  142. package/dist/localization/messages_is.js.map +1 -1
  143. package/dist/localization/messages_is.min.js +2 -2
  144. package/dist/localization/messages_is.min.js.map +1 -1
  145. package/dist/localization/messages_it.esm.js +2 -2
  146. package/dist/localization/messages_it.js +3 -3
  147. package/dist/localization/messages_it.js.map +1 -1
  148. package/dist/localization/messages_it.min.js +2 -2
  149. package/dist/localization/messages_it.min.js.map +1 -1
  150. package/dist/localization/messages_ja.esm.js +2 -2
  151. package/dist/localization/messages_ja.js +3 -3
  152. package/dist/localization/messages_ja.js.map +1 -1
  153. package/dist/localization/messages_ja.min.js +2 -2
  154. package/dist/localization/messages_ja.min.js.map +1 -1
  155. package/dist/localization/messages_ka.esm.js +2 -2
  156. package/dist/localization/messages_ka.js +3 -3
  157. package/dist/localization/messages_ka.js.map +1 -1
  158. package/dist/localization/messages_ka.min.js +2 -2
  159. package/dist/localization/messages_ka.min.js.map +1 -1
  160. package/dist/localization/messages_kk.esm.js +2 -2
  161. package/dist/localization/messages_kk.js +3 -3
  162. package/dist/localization/messages_kk.js.map +1 -1
  163. package/dist/localization/messages_kk.min.js +2 -2
  164. package/dist/localization/messages_kk.min.js.map +1 -1
  165. package/dist/localization/messages_ko.esm.js +2 -2
  166. package/dist/localization/messages_ko.js +3 -3
  167. package/dist/localization/messages_ko.js.map +1 -1
  168. package/dist/localization/messages_ko.min.js +2 -2
  169. package/dist/localization/messages_ko.min.js.map +1 -1
  170. package/dist/localization/messages_lt.esm.js +2 -2
  171. package/dist/localization/messages_lt.js +3 -3
  172. package/dist/localization/messages_lt.js.map +1 -1
  173. package/dist/localization/messages_lt.min.js +2 -2
  174. package/dist/localization/messages_lt.min.js.map +1 -1
  175. package/dist/localization/messages_lv.esm.js +2 -2
  176. package/dist/localization/messages_lv.js +3 -3
  177. package/dist/localization/messages_lv.js.map +1 -1
  178. package/dist/localization/messages_lv.min.js +2 -2
  179. package/dist/localization/messages_lv.min.js.map +1 -1
  180. package/dist/localization/messages_mk.esm.js +2 -2
  181. package/dist/localization/messages_mk.js +3 -3
  182. package/dist/localization/messages_mk.js.map +1 -1
  183. package/dist/localization/messages_mk.min.js +2 -2
  184. package/dist/localization/messages_mk.min.js.map +1 -1
  185. package/dist/localization/messages_my.esm.js +2 -2
  186. package/dist/localization/messages_my.js +3 -3
  187. package/dist/localization/messages_my.js.map +1 -1
  188. package/dist/localization/messages_my.min.js +2 -2
  189. package/dist/localization/messages_my.min.js.map +1 -1
  190. package/dist/localization/messages_nl.esm.js +2 -2
  191. package/dist/localization/messages_nl.js +3 -3
  192. package/dist/localization/messages_nl.js.map +1 -1
  193. package/dist/localization/messages_nl.min.js +2 -2
  194. package/dist/localization/messages_nl.min.js.map +1 -1
  195. package/dist/localization/messages_no.esm.js +2 -2
  196. package/dist/localization/messages_no.js +3 -3
  197. package/dist/localization/messages_no.js.map +1 -1
  198. package/dist/localization/messages_no.min.js +2 -2
  199. package/dist/localization/messages_no.min.js.map +1 -1
  200. package/dist/localization/messages_pl.esm.js +2 -2
  201. package/dist/localization/messages_pl.js +3 -3
  202. package/dist/localization/messages_pl.js.map +1 -1
  203. package/dist/localization/messages_pl.min.js +2 -2
  204. package/dist/localization/messages_pl.min.js.map +1 -1
  205. package/dist/localization/messages_pt_BR.esm.js +2 -2
  206. package/dist/localization/messages_pt_BR.js +3 -3
  207. package/dist/localization/messages_pt_BR.js.map +1 -1
  208. package/dist/localization/messages_pt_BR.min.js +2 -2
  209. package/dist/localization/messages_pt_BR.min.js.map +1 -1
  210. package/dist/localization/messages_pt_PT.esm.js +2 -2
  211. package/dist/localization/messages_pt_PT.js +3 -3
  212. package/dist/localization/messages_pt_PT.js.map +1 -1
  213. package/dist/localization/messages_pt_PT.min.js +2 -2
  214. package/dist/localization/messages_pt_PT.min.js.map +1 -1
  215. package/dist/localization/messages_ro.esm.js +2 -2
  216. package/dist/localization/messages_ro.js +3 -3
  217. package/dist/localization/messages_ro.js.map +1 -1
  218. package/dist/localization/messages_ro.min.js +2 -2
  219. package/dist/localization/messages_ro.min.js.map +1 -1
  220. package/dist/localization/messages_ru.esm.js +2 -2
  221. package/dist/localization/messages_ru.js +3 -3
  222. package/dist/localization/messages_ru.js.map +1 -1
  223. package/dist/localization/messages_ru.min.js +2 -2
  224. package/dist/localization/messages_ru.min.js.map +1 -1
  225. package/dist/localization/messages_sd.esm.js +2 -2
  226. package/dist/localization/messages_sd.js +3 -3
  227. package/dist/localization/messages_sd.js.map +1 -1
  228. package/dist/localization/messages_sd.min.js +2 -2
  229. package/dist/localization/messages_sd.min.js.map +1 -1
  230. package/dist/localization/messages_si.esm.js +2 -2
  231. package/dist/localization/messages_si.js +3 -3
  232. package/dist/localization/messages_si.js.map +1 -1
  233. package/dist/localization/messages_si.min.js +2 -2
  234. package/dist/localization/messages_si.min.js.map +1 -1
  235. package/dist/localization/messages_sk.esm.js +2 -2
  236. package/dist/localization/messages_sk.js +3 -3
  237. package/dist/localization/messages_sk.js.map +1 -1
  238. package/dist/localization/messages_sk.min.js +2 -2
  239. package/dist/localization/messages_sk.min.js.map +1 -1
  240. package/dist/localization/messages_sl.esm.js +2 -2
  241. package/dist/localization/messages_sl.js +3 -3
  242. package/dist/localization/messages_sl.js.map +1 -1
  243. package/dist/localization/messages_sl.min.js +2 -2
  244. package/dist/localization/messages_sl.min.js.map +1 -1
  245. package/dist/localization/messages_sr.esm.js +2 -2
  246. package/dist/localization/messages_sr.js +3 -3
  247. package/dist/localization/messages_sr.js.map +1 -1
  248. package/dist/localization/messages_sr.min.js +2 -2
  249. package/dist/localization/messages_sr.min.js.map +1 -1
  250. package/dist/localization/messages_sr_lat.esm.js +2 -2
  251. package/dist/localization/messages_sr_lat.js +3 -3
  252. package/dist/localization/messages_sr_lat.js.map +1 -1
  253. package/dist/localization/messages_sr_lat.min.js +2 -2
  254. package/dist/localization/messages_sr_lat.min.js.map +1 -1
  255. package/dist/localization/messages_sv.esm.js +2 -2
  256. package/dist/localization/messages_sv.js +3 -3
  257. package/dist/localization/messages_sv.js.map +1 -1
  258. package/dist/localization/messages_sv.min.js +2 -2
  259. package/dist/localization/messages_sv.min.js.map +1 -1
  260. package/dist/localization/messages_th.esm.js +2 -2
  261. package/dist/localization/messages_th.js +3 -3
  262. package/dist/localization/messages_th.js.map +1 -1
  263. package/dist/localization/messages_th.min.js +2 -2
  264. package/dist/localization/messages_th.min.js.map +1 -1
  265. package/dist/localization/messages_tj.esm.js +2 -2
  266. package/dist/localization/messages_tj.js +3 -3
  267. package/dist/localization/messages_tj.js.map +1 -1
  268. package/dist/localization/messages_tj.min.js +2 -2
  269. package/dist/localization/messages_tj.min.js.map +1 -1
  270. package/dist/localization/messages_tr.esm.js +2 -2
  271. package/dist/localization/messages_tr.js +3 -3
  272. package/dist/localization/messages_tr.js.map +1 -1
  273. package/dist/localization/messages_tr.min.js +2 -2
  274. package/dist/localization/messages_tr.min.js.map +1 -1
  275. package/dist/localization/messages_uk.esm.js +2 -2
  276. package/dist/localization/messages_uk.js +3 -3
  277. package/dist/localization/messages_uk.js.map +1 -1
  278. package/dist/localization/messages_uk.min.js +2 -2
  279. package/dist/localization/messages_uk.min.js.map +1 -1
  280. package/dist/localization/messages_ur.esm.js +2 -2
  281. package/dist/localization/messages_ur.js +3 -3
  282. package/dist/localization/messages_ur.js.map +1 -1
  283. package/dist/localization/messages_ur.min.js +2 -2
  284. package/dist/localization/messages_ur.min.js.map +1 -1
  285. package/dist/localization/messages_vi.esm.js +2 -2
  286. package/dist/localization/messages_vi.js +3 -3
  287. package/dist/localization/messages_vi.js.map +1 -1
  288. package/dist/localization/messages_vi.min.js +2 -2
  289. package/dist/localization/messages_vi.min.js.map +1 -1
  290. package/dist/localization/messages_zh.esm.js +2 -2
  291. package/dist/localization/messages_zh.js +3 -3
  292. package/dist/localization/messages_zh.js.map +1 -1
  293. package/dist/localization/messages_zh.min.js +2 -2
  294. package/dist/localization/messages_zh.min.js.map +1 -1
  295. package/dist/localization/messages_zh_TW.esm.js +2 -2
  296. package/dist/localization/messages_zh_TW.js +3 -3
  297. package/dist/localization/messages_zh_TW.js.map +1 -1
  298. package/dist/localization/messages_zh_TW.min.js +2 -2
  299. package/dist/localization/messages_zh_TW.min.js.map +1 -1
  300. package/dist/localization/methods_de.esm.js +2 -2
  301. package/dist/localization/methods_de.js +3 -3
  302. package/dist/localization/methods_de.js.map +1 -1
  303. package/dist/localization/methods_de.min.js +2 -2
  304. package/dist/localization/methods_de.min.js.map +1 -1
  305. package/dist/localization/methods_es_CL.esm.js +2 -2
  306. package/dist/localization/methods_es_CL.js +3 -3
  307. package/dist/localization/methods_es_CL.js.map +1 -1
  308. package/dist/localization/methods_es_CL.min.js +2 -2
  309. package/dist/localization/methods_es_CL.min.js.map +1 -1
  310. package/dist/localization/methods_fi.esm.js +2 -2
  311. package/dist/localization/methods_fi.js +3 -3
  312. package/dist/localization/methods_fi.js.map +1 -1
  313. package/dist/localization/methods_fi.min.js +2 -2
  314. package/dist/localization/methods_fi.min.js.map +1 -1
  315. package/dist/localization/methods_it.esm.js +2 -2
  316. package/dist/localization/methods_it.js +3 -3
  317. package/dist/localization/methods_it.js.map +1 -1
  318. package/dist/localization/methods_it.min.js +2 -2
  319. package/dist/localization/methods_it.min.js.map +1 -1
  320. package/dist/localization/methods_nl.esm.js +2 -2
  321. package/dist/localization/methods_nl.js +3 -3
  322. package/dist/localization/methods_nl.js.map +1 -1
  323. package/dist/localization/methods_nl.min.js +2 -2
  324. package/dist/localization/methods_nl.min.js.map +1 -1
  325. package/dist/localization/methods_pt.esm.js +2 -2
  326. package/dist/localization/methods_pt.js +3 -3
  327. package/dist/localization/methods_pt.js.map +1 -1
  328. package/dist/localization/methods_pt.min.js +2 -2
  329. package/dist/localization/methods_pt.min.js.map +1 -1
  330. package/dist/types/defaults.d.ts.map +1 -1
  331. package/dist/types/eventManager.d.ts +6 -1
  332. package/dist/types/eventManager.d.ts.map +1 -1
  333. package/dist/types/helpers.d.ts +19 -0
  334. package/dist/types/helpers.d.ts.map +1 -1
  335. package/dist/types/index.d.ts +20 -3
  336. package/dist/types/index.d.ts.map +1 -1
  337. package/dist/types/messages.d.ts +2 -2
  338. package/dist/types/messages.d.ts.map +1 -1
  339. package/dist/types/methods.d.ts.map +1 -1
  340. package/dist/types/objectStore.d.ts +6 -0
  341. package/dist/types/objectStore.d.ts.map +1 -1
  342. package/dist/types/rules.d.ts.map +1 -1
  343. package/dist/types/types.d.ts +34 -8
  344. package/dist/types/types.d.ts.map +1 -1
  345. package/dist/types/unobtrusive.d.ts +104 -0
  346. package/dist/types/unobtrusive.d.ts.map +1 -0
  347. package/dist/types/validator.d.ts +62 -3
  348. package/dist/types/validator.d.ts.map +1 -1
  349. package/package.json +27 -8
@@ -1 +1 @@
1
- {"version":3,"file":"dv.min.js","sources":["../src/helpers.ts","../src/objectStore.ts","../src/methods.ts","../src/rules.ts","../src/messages.ts","../src/validatorStore.ts","../src/eventManager.ts","../src/defaults.ts","../src/validator.ts","../src/index.ts"],"sourcesContent":["import { FormControlElement } from './types';\n\n/**\n * Returns true if the element is visible in the DOM.\n * @param el - element to check visibility\n * @return true if element is visible, false otherwise\n */\nexport function isVisible(el: HTMLElement): boolean {\n return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);\n}\n\n/**\n * Returns the number of truthy properties in an object.\n * @param obj - object to count properties\n * @return count of truthy properties\n */\nexport function objectLength(obj: any): number {\n let count = 0;\n for (const key in obj) {\n // This check allows counting elements with empty error message as invalid elements\n if (obj[key] !== undefined && obj[key] !== null && obj[key] !== false) {\n count++;\n }\n }\n return count;\n}\n\n/**\n * Finds all form elements with the specified name attribute.\n * @param form - form element to search within\n * @param name - name attribute to search for\n * @return array of matching elements\n */\nexport function findByName(\n form: HTMLFormElement,\n name: string,\n): FormControlElement[] {\n const selector = `[name='${escapeCssMeta(name)}']`;\n\n const elements = Array.from(form.querySelectorAll(selector));\n\n if (form.id) {\n const outsideElements = Array.from(\n document.querySelectorAll(selector),\n ).filter((el) => el.matches(`[form=\"${escapeCssMeta(form.id)}\"]`));\n elements.push(...outsideElements);\n }\n\n return elements as FormControlElement[];\n}\n\n/**\n * Returns true if the element is a radio button or checkbox.\n * @param element - element to check\n * @return true if element is radio or checkbox, false otherwise\n */\nexport function isCheckableElement(element: FormControlElement): boolean {\n return /radio|checkbox/i.test(element.type || '');\n}\n\n/**\n * Escapes CSS meta-characters in a string for use in CSS selectors.\n * See https://api.jquery.com/category/selectors/ for CSS meta-characters that should be escaped.\n * @param text - text to escape\n * @return escaped text safe for CSS selectors\n */\nexport function escapeCssMeta(text: string): string {\n if (text === undefined) {\n return '';\n }\n\n return text.replace(/([\\\\!\"#$%&'()*+,./:;<=>?@\\[\\]^`{|}~])/g, '\\\\$1');\n}\n\n/**\n * Gets the value of a form element, handling special cases for different input types.\n * @param element - form control element to get value of\n * @param form - current html form being validated\n * @return element value or array of values for checkboxes/radios\n */\nexport function elementValue(\n element: FormControlElement,\n form: HTMLFormElement,\n): string | string[] {\n if (element.type === 'radio' || element.type === 'checkbox') {\n const checked = findByName(form, element.name).filter((el) =>\n el.matches(':checked'),\n );\n return checked.map((el) => el.value);\n }\n if (element.type === 'number' && typeof element.validity !== 'undefined') {\n return element.validity.badInput ? 'NaN' : element.value;\n }\n if (element.type === 'file') {\n return fileInputValue(element);\n }\n\n return element.value.replace(/\\r/g, '');\n}\n\n/**\n * Get the value of a file input element.\n * @param element - file input element\n * @return file path or file name\n */\nexport function fileInputValue(element: FormControlElement): string {\n const value = element.value;\n\n // Modern browser (chrome & safari)\n if (value.substring(0, 12) === 'C:\\\\fakepath\\\\') {\n return value.substring(12);\n }\n\n // Legacy browsers\n // Unix-based path\n let idx = value.lastIndexOf('/');\n if (idx >= 0) {\n return value.substring(idx + 1);\n }\n\n // Windows-based path\n idx = value.lastIndexOf('\\\\');\n if (idx >= 0) {\n return value.substring(idx + 1);\n }\n\n // Just the file name\n return value;\n}\n\n/**\n * Formats a string by replacing {0}, {1}, etc. placeholders with provided parameters.\n * @param source - template string with placeholders\n * @param params - parameters to substitute into placeholders\n * @return formatted string or curried function if only source provided\n */\nexport function format(\n source: string,\n params?: any,\n): ((...args: any[]) => string) | string {\n // If no params provided, return a curried function\n if (params === undefined) {\n return function (args: any[]) {\n return formatString(source, args);\n };\n }\n\n if (!Array.isArray(params)) {\n params = [params];\n }\n\n return formatString(source, params);\n}\n\n/**\n * Internal helper to format a string with parameters.\n * @param source - template string with placeholders\n * @param params - parameters to substitute\n * @return formatted string\n */\nfunction formatString(source: string, params: any[]): string {\n if (!Array.isArray(params)) {\n params = [params];\n }\n\n params.forEach((param: any, index: number) => {\n source = source.replace(new RegExp(`\\\\{${index}\\\\}`, 'g'), String(param));\n });\n\n return source;\n}\n\n/**\n * Returns the id or name attribute of an element, preferring name for checkable elements.\n * @param element - element to get identifier from\n * @return element id or name\n */\nexport function idOrName(element: FormControlElement): string {\n return (\n (isCheckableElement(element) ? element.name : element.id) || element.name\n );\n}\n\n/**\n * Gets the length of a form element's value, handling special cases for selects and checkables.\n * @param element - form control element\n * @param form - html form element\n * @return length of the element's value\n */\nexport function getValueLength(\n element: FormControlElement,\n form: HTMLFormElement,\n): number {\n const nodeName = element.nodeName.toLowerCase();\n const value = elementValue(element, form);\n\n if (nodeName === 'select') {\n return element.querySelectorAll('option:checked').length;\n } else if (nodeName === 'input' && isCheckableElement(element)) {\n return findByName(form, element.name).filter((el) => el.matches(':checked'))\n .length;\n }\n\n return value.length;\n}\n\n/**\n * Returns true if the element has no value or is considered blank.\n * @param element - form control element to check\n * @param form - current form element\n * @return true if element is blank, false otherwise\n */\nexport function isBlankElement(\n element: FormControlElement,\n form: HTMLFormElement,\n): boolean {\n const value = elementValue(element, form);\n\n if (element.nodeName.toLowerCase() === 'select' && element.selectedOptions) {\n const selected = Array.from(element.selectedOptions).map((o) => o.value);\n\n return selected.length === 0 || !selected[0];\n }\n\n if (isCheckableElement(element)) {\n return getValueLength(element, form) === 0;\n }\n\n return value === undefined || value === null || value.length === 0;\n}\n\nconst displayDataMap = new WeakMap();\n\n/**\n * Shows an element by restoring its original display value.\n * Matches jQuery's .show() behavior.\n * @param element - Element to show\n */\nexport function showElement(element: HTMLElement): void {\n const storedDisplay = displayDataMap.get(element);\n if (storedDisplay) {\n element.style.display = storedDisplay;\n displayDataMap.delete(element);\n } else {\n element.style.display = '';\n }\n}\n\n/**\n * Hides an element by setting display to none, storing the original display value.\n * Matches jQuery's .hide() behavior.\n * @param element - Element to hide\n */\nexport function hideElement(element: HTMLElement): void {\n if (element.style.display !== 'none') {\n // Store current display value\n displayDataMap.set(\n element,\n element.style.display || getComputedStyle(element).display,\n );\n element.style.display = 'none';\n }\n}\n","export class ObjectStore<T> {\n private readonly _store: Record<string, T> = {};\n\n constructor(data: Record<string, T>) {\n this._store = data;\n }\n\n keys(): string[] {\n return Object.keys(this._store);\n }\n\n get(key: string): T | undefined {\n return this._store[key];\n }\n\n set(key: string, value: T): void {\n this._store[key] = value;\n }\n\n replace(data: Record<string, T>): void {\n Object.entries(data).forEach(([key, value]) => {\n if (key in this._store) {\n this._store[key] = value;\n }\n });\n }\n}\n","import { ValidationMethod, ValidationMethodInput } from './types';\nimport { ObjectStore } from './objectStore';\n\n/**\n * Public API for accessing and managing validation methods.\n */\nexport const store = new ObjectStore<ValidationMethod>({\n required,\n minlength: minLength,\n maxlength: maxLength,\n rangelength: rangeLength,\n min,\n max,\n range,\n email,\n url,\n date,\n dateISO,\n number,\n digits,\n equalTo,\n regex,\n nonalphamin: nonAlphaMin,\n creditcard: creditCard,\n});\n\n/**\n * Validates that the field has a value (is not blank).\n * @return true if field is not blank\n */\nfunction required({ blank }: ValidationMethodInput): boolean {\n return !blank;\n}\n\n/**\n * Validates that the field value has at least the minimum length.\n * @return true if blank or length meets minimum\n */\nfunction minLength({ blank, length, param }: ValidationMethodInput): boolean {\n return blank || length >= param;\n}\n\n/**\n * Validates that the field value does not exceed the maximum length.\n * @return true if blank or length within maximum\n */\nfunction maxLength({ blank, length, param }: ValidationMethodInput): boolean {\n return blank || length <= param;\n}\n\n/**\n * Validates that the field value length is within a specified range.\n * @return true if blank or length within range\n */\nfunction rangeLength({ blank, length, param }: ValidationMethodInput): boolean {\n return blank || (length >= param[0] && length <= param[1]);\n}\n\n/**\n * Validates that the field value is greater than or equal to a minimum value.\n * @return true if blank or value meets minimum\n */\nfunction min({ blank, value, param }: ValidationMethodInput): boolean {\n return blank || value >= param;\n}\n\n/**\n * Validates that the field value is less than or equal to a maximum value.\n * @return true if blank or value within maximum\n */\nfunction max({ blank, value, param }: ValidationMethodInput): boolean {\n return blank || value <= param;\n}\n\n/**\n * Validates that the field value is within a specified numeric range.\n * @return true if blank or value within range\n */\nfunction range({ blank, value, param }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n return value >= param[0] && value <= param[1];\n}\n\n/**\n * Validates that the field value is a valid email address format.\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid email format\n */\nfunction email({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const re =\n /^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;\n\n return re.test(value);\n}\n\n/**\n * Validates that the field value is a valid URL format.\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid URL format\n */\nfunction url({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const re =\n /^(?:(?:https?|ftp):)?\\/\\/(?:(?:[^\\]\\[?\\/<~#`!@$^&*()+=}|:\";',>{ ]|%[0-9A-Fa-f]{2})+(?::(?:[^\\]\\[?\\/<~#`!@$^&*()+=}|:\";',>{ ]|%[0-9A-Fa-f]{2})*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4])|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+[a-z\\u00a1-\\uffff]{2,}\\.?)(?::\\d{2,5})?(?:[\\/?#]\\S*)?$/i;\n\n return re.test(value);\n}\n\n/**\n * Validates that the field value is a valid date string\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid date string\n */\nfunction date({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n return !/Invalid|NaN/.test(new Date(value).toString());\n}\n\n/**\n * Validates that the field value is a valid ISO date format (YYYY-MM-DD or YYYY/MM/DD).\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid ISO date format\n */\nfunction dateISO({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const re = /^\\d{4}[\\/\\-](0?[1-9]|1[012])[\\/\\-](0?[1-9]|[12][0-9]|3[01])$/;\n return re.test(value);\n}\n\n/**\n * Validates that the field value is a valid number (including decimals and comma-separated thousands).\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid number format\n */\nfunction number({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const re = /^(?:-?\\d+|-?\\d{1,3}(?:,\\d{3})+)?(?:-?\\.\\d+)?$/;\n return re.test(value);\n}\n\n/**\n * Validates that the field value contains only digits (no decimals or special characters).\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or contains only digits\n */\nfunction digits({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n return /^\\d+$/.test(value);\n}\n\n/**\n * Validates that the field value equals the value of another field (e.g., password confirmation).\n * @return true if values match\n */\nfunction equalTo({ value, param }: ValidationMethodInput): boolean {\n const target = document.querySelector(param);\n return value === target.value;\n}\n\n/**\n * Validates that the field value matches a regular expression.\n * @return true if blank or value matches pattern\n */\nfunction regex({ blank, value, param }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const match = new RegExp(param).exec(value);\n return !!match && match.index === 0 && match[0].length === value.length;\n}\n\n/**\n * Validates that the field value contains at least a minimum number of non-alphanumeric characters.\n * Used for password strength validation.\n * @return true if blank or value has enough non-alphanumeric characters\n */\nfunction nonAlphaMin({ blank, value, param }: ValidationMethodInput): boolean {\n if (blank || !param) {\n return true;\n }\n\n const match = value.match(/\\W/g);\n return !!match && match.length >= param;\n}\n\n/**\n * Validates that the field value matches a credit card number.\n * based on https://en.wikipedia.org/wiki/Luhn_algorithm\n * @return true if blank or value is a valid credit card number\n */\nfunction creditCard({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const strippedValue = value.replace(/\\D/g, '');\n\n let nCheck = 0;\n let bEven = false;\n\n // Basing min and max length on\n // https://dev.ean.com/general-info/valid-card-types/\n if (strippedValue.length < 13 || strippedValue.length > 19) {\n return false;\n }\n\n for (let n = strippedValue.length - 1; n >= 0; n--) {\n const cDigit = strippedValue.charAt(n);\n let nDigit = parseInt(cDigit, 10);\n if (bEven) {\n if ((nDigit *= 2) > 9) {\n nDigit -= 9;\n }\n }\n\n nCheck += nDigit;\n bEven = !bEven;\n }\n\n return nCheck % 10 === 0;\n}\n","import { store as methodStore } from './methods';\nimport { FormControlElement, ValidationRuleset } from './types';\n\n/**\n * Gets all validation rules for an element from multiple sources.\n * Merges rules from CSS classes, HTML attributes, data attributes, and programmatic settings.\n * @param element - form element to get rules for\n * @param settings - validator rule settings\n * @return {Object} - object containing all validation rules with the required rule first\n */\nexport function getRules(\n element: FormControlElement,\n settings: Record<string, ValidationRuleset>,\n): ValidationRuleset {\n // If nothing is selected, return empty object; can't chain anyway\n if (element == null || element.form == null) {\n return {};\n }\n\n let data = normalizeRules({\n ...classRules(element),\n ...attributeRules(element),\n ...dataRules(element),\n ...staticRules(element, settings),\n });\n\n // Make sure required is at front\n if (data.required) {\n const param = data.required;\n delete data.required;\n data = { required: param, ...data };\n }\n\n return data;\n}\n\n/**\n * Default mapping of CSS class names to validation rules.\n * Allows class-based rule declaration like class=\"required email\".\n */\nconst classRuleSettings: Record<string, ValidationRuleset> = {\n required: { required: true },\n email: { email: true },\n url: { url: true },\n date: { date: true },\n dateISO: { dateISO: true },\n number: { number: true },\n digits: { digits: true },\n creditcard: { creditcard: true },\n};\n\n/**\n * Adds or updates validation rules for a CSS class name.\n * @param className - class name to associate with rules\n */\nexport function addClassRule(className: string): void {\n classRuleSettings[className] = normalizeRule(className);\n}\n\n/**\n * Normalizes and processes validation rules for an element.\n * Removes false rules, evaluates function parameters, and converts string/number values.\n * @param rules - raw validation rules object\n * @return normalized rules object\n */\nfunction normalizeRules(rules: ValidationRuleset): ValidationRuleset {\n Object.entries(rules).forEach(([key, value]) => {\n // Ignore rule when param is explicitly false, eg. required:false\n if (value === false) {\n delete rules[key];\n return;\n }\n\n if (typeof value === 'object' && 'param' in value && value.param) {\n rules[key] = value.param;\n }\n });\n\n // Clean number parameters\n ['minlength', 'maxlength'].forEach((ruleKey) => {\n if (rules[ruleKey]) {\n rules[ruleKey] = Number(rules[ruleKey]);\n }\n });\n ['rangelength', 'range'].forEach((ruleKey) => {\n if (rules[ruleKey]) {\n if (Array.isArray(rules[ruleKey])) {\n rules[ruleKey] = [rules[ruleKey][0], rules[ruleKey][1]].map(Number) as [\n number,\n number,\n ];\n } else {\n const parts = rules[ruleKey]\n .toString()\n .replace(/[\\[\\]]/g, '')\n .split(/[\\s,]+/);\n rules[ruleKey] = [parts[0], parts[1]].map(Number) as [number, number];\n }\n }\n });\n\n return rules;\n}\n\n/**\n * Extracts validation rules from an element's CSS classes.\n * @param element - element to extract rules from\n * @return validation rules derived from CSS classes\n */\nfunction classRules(element: FormControlElement): ValidationRuleset {\n let rules = {};\n const classes = element.getAttribute('class');\n\n if (classes) {\n classes.split(' ').forEach((className: string) => {\n if (className in classRuleSettings) {\n rules = { ...rules, ...classRuleSettings[className] };\n }\n });\n }\n\n return rules;\n}\n\n/**\n * Extracts validation rules from HTML attributes (required, minlength, etc.).\n * @param element - element to extract rules from\n * @return validation rules derived from HTML attributes\n */\nfunction attributeRules(element: FormControlElement): ValidationRuleset {\n const rules: ValidationRuleset = {};\n const type = element.type;\n\n for (const method of methodStore.keys()) {\n let value: string | null | boolean = element.getAttribute(method);\n\n // Support for <input required> in both html5 and older browsers\n if (method === 'required') {\n // Some browsers return an empty string for the required attribute\n // and non-HTML5 browsers might have required=\"\" markup\n if (value === '') {\n value = true;\n }\n\n // Force non-HTML5 browsers to return bool\n value = !!value;\n }\n\n normalizeAttributeRule(rules, type, method, value);\n }\n\n // 'maxlength' may be returned as -1, 2147483647 ( IE ) and 524288 ( safari ) for text inputs\n if (\n rules.maxlength &&\n /-1|2147483647|524288/.test(rules.maxlength.toString())\n ) {\n delete rules.maxlength;\n }\n\n return rules;\n}\n\n/**\n * Extracts validation rules from data attributes (data-rule-required, etc.).\n * @param element - element to extract rules from\n * @return validation rules derived from data attributes\n */\nfunction dataRules(element: FormControlElement): ValidationRuleset {\n const rules = {};\n const type = element.type;\n\n for (const method of methodStore.keys()) {\n const datasetKey =\n 'rule' +\n method.charAt(0).toUpperCase() +\n method.substring(1).toLowerCase();\n let value: string | null | boolean = element.dataset[datasetKey] ?? null;\n\n // Cast empty attributes like `data-rule-required` to `true`\n if (value === '' || value === 'true') {\n value = true;\n } else if (value === 'false') {\n value = false;\n }\n\n normalizeAttributeRule(rules, type, method, value);\n }\n\n return rules;\n}\n\n/**\n * Gets validation rules defined programmatically in validator settings.\n * @param element - element to get rules for\n * @param settings - Validator rule settings\n * @return validation rules from validator settings\n */\nexport function staticRules(\n element: FormControlElement,\n settings: Record<string, ValidationRuleset>,\n): ValidationRuleset {\n if (!settings || !settings[element.name]) {\n return {};\n }\n\n return normalizeRule(settings[element.name]!) || {};\n}\n\n/**\n * Normalizes a single attribute rule and adds it to the rules object.\n * Handles type coercion and special cases for different input types.\n * @param rules - rules object to add the rule to\n * @param type - input type attribute value\n * @param method - validation method name\n * @param value - attribute value\n */\nfunction normalizeAttributeRule(\n rules: ValidationRuleset,\n type: string,\n method: string,\n value: string | number | boolean | null,\n): void {\n // Convert the value to a number for number inputs, and for text for backwards compatability\n // allows type=\"date\" and others to be compared as strings\n if (\n /min|max|step/.test(method) &&\n (type === null || /number|range|text/.test(type)) &&\n value !== null\n ) {\n value = Number(value);\n }\n\n if (value || value === 0) {\n rules[method] = value;\n } else if (type === method && type !== 'range') {\n // Exception: the jquery validate 'range' method\n // does not test for the html5 'range' type\n rules[type === 'date' ? 'dateISO' : method] = true;\n }\n}\n\n/**\n * Converts string-based rule declarations to rule objects.\n * Transforms \"required email\" to {required: true, email: true}.\n * @param data - rule string or object\n * @return normalized rule object\n */\nexport function normalizeRule(\n data: ValidationRuleset | string,\n): ValidationRuleset {\n if (typeof data !== 'string') {\n return data;\n }\n\n const transformed: ValidationRuleset = {};\n data.split(/\\s/).forEach((token) => {\n transformed[token] = true;\n });\n\n return transformed;\n}\n","import { format } from './helpers';\nimport { Validator } from './validator';\nimport { FormControlElement } from './types';\nimport { ObjectStore } from './objectStore';\n\n/**\n * Public API for accessing and managing error messages.\n */\nexport const store = new ObjectStore<string>({\n required: 'This field is required.',\n email: 'Please enter a valid email address.',\n url: 'Please enter a valid URL.',\n date: 'Please enter a valid date.',\n dateISO: 'Please enter a valid date (ISO).',\n number: 'Please enter a valid number.',\n digits: 'Please enter only digits.',\n equalTo: 'Please enter the same value again.',\n maxlength: 'Please enter no more than {0} characters.',\n minlength: 'Please enter at least {0} characters.',\n rangelength: 'Please enter a value between {0} and {1} characters long.',\n range: 'Please enter a value between {0} and {1}.',\n max: 'Please enter a value less than or equal to {0}.',\n min: 'Please enter a value greater than or equal to {0}.',\n\n regex: 'Please enter a value that matches the pattern {0}.',\n nonalphamin: 'Please enter at least {0} non-alphabetic characters.',\n creditcard: 'Please enter a valid credit card number.',\n});\n\n/**\n * Gets the appropriate error message for a validation rule failure.\n * Checks custom messages, data attributes, element title, and default messages in order.\n * @param element - form element that failed validation\n * @param rule - validation rule (string method name or object with method and parameters)\n * @param ignoreTitle - whether to ignore element title\n * @param customMessage - validator settings that may contain custom messages\n * @return formatted error message\n */\nexport function getMessage(\n this: Validator,\n element: FormControlElement,\n rule: { method: string; parameters?: any },\n ignoreTitle: boolean,\n customMessage?: string,\n): string {\n let message: string = [\n customMessage,\n customDataMessage(element, rule.method),\n (!ignoreTitle && element.title) || undefined,\n store.get(rule.method),\n `<strong>Warning: No message defined for ${element.name}</strong>`,\n ].find((x) => x !== undefined) as string;\n\n const regex = /\\$?\\{(\\d+)}/g;\n\n if (/\\$?\\{(\\d+)}/g.test(message)) {\n return format(message.replace(regex, '{$1}'), rule.parameters) as string;\n } else {\n return message;\n }\n}\n\n/**\n * Gets a custom error message from element's data attributes.\n * Checks data-msg-{method} first, then falls back to data-msg.\n * @param element - form element\n * @param method - validation method name\n * @return custom message from data attribute if present\n */\nfunction customDataMessage(\n element: FormControlElement,\n method: string,\n): string | undefined {\n const dataSetKey =\n 'msg' + method.charAt(0).toUpperCase() + method.substring(1).toLowerCase();\n\n if (!element?.dataset) {\n return;\n }\n\n return element.dataset[dataSetKey] || element.dataset['msg'];\n}\n","import { Validator } from './validator';\n\nexport const validatorStore = new WeakMap<HTMLFormElement, Validator>();\n","import {\n FormControlElement,\n ValidationError,\n ValidatorSettings,\n} from './types';\n\n/**\n * CSS selectors for different types of form elements that should receive validation events\n */\nconst EVENT_TARGETS = {\n FOCUS_TARGETS: [\n \"[type='text']\",\n \"[type='password']\",\n \"[type='file']\",\n 'select',\n 'textarea',\n \"[type='number']\",\n \"[type='search']\",\n \"[type='tel']\",\n \"[type='url']\",\n \"[type='email']\",\n \"[type='datetime']\",\n \"[type='date']\",\n \"[type='month']\",\n \"[type='week']\",\n \"[type='time']\",\n \"[type='datetime-local']\",\n \"[type='range']\",\n \"[type='color']\",\n \"[type='radio']\",\n \"[type='checkbox']\",\n 'button',\n \"input[type='button']\",\n ],\n CLICK_TARGETS: ['select', \"[type='radio']\", \"[type='checkbox']\"],\n} as const;\n\n/**\n * Event handler function type for validation events\n */\ntype ValidationEventHandler =\n | boolean\n | ((element: FormControlElement, event: Event) => void);\n\n/**\n * Manages event delegation for form validation.\n * Handles attaching and removing event listeners with proper delegation logic.\n */\nexport class FormEventManager {\n private boundEventHandlers: {\n onFocusIn: ((e: Event) => void) | null;\n onFocusOut: ((e: Event) => void) | null;\n onKeyUp: ((e: Event) => void) | null;\n onClick: ((e: Event) => void) | null;\n } = {\n onFocusIn: null,\n onFocusOut: null,\n onKeyUp: null,\n onClick: null,\n };\n\n constructor(\n private form: HTMLFormElement,\n private settings: ValidatorSettings,\n private validateCallback: () => boolean,\n private focusInvalidCallback: () => void,\n private shouldIgnoreElement: (element: HTMLElement) => boolean,\n ) {}\n\n /**\n * Attaches all validation event listeners to the form\n */\n attachEventHandlers(): void {\n this.boundEventHandlers.onFocusIn = this.createDelegate(\n EVENT_TARGETS.FOCUS_TARGETS,\n this.settings.onfocusin,\n );\n this.boundEventHandlers.onFocusOut = this.createDelegate(\n EVENT_TARGETS.FOCUS_TARGETS,\n this.settings.onfocusout,\n );\n this.boundEventHandlers.onKeyUp = this.createDelegate(\n EVENT_TARGETS.FOCUS_TARGETS,\n this.settings.onkeyup,\n );\n this.boundEventHandlers.onClick = this.createDelegate(\n EVENT_TARGETS.CLICK_TARGETS,\n this.settings.onclick,\n );\n\n this.form.addEventListener('focusin', this.boundEventHandlers.onFocusIn);\n this.form.addEventListener('focusout', this.boundEventHandlers.onFocusOut);\n this.form.addEventListener('keyup', this.boundEventHandlers.onKeyUp);\n this.form.addEventListener('click', this.boundEventHandlers.onClick);\n\n if (this.settings.onsubmit) {\n this.form.addEventListener('submit', (e: SubmitEvent) =>\n this.handleSubmitForm(e),\n );\n }\n\n const invalidHandler = this.settings.invalidHandler;\n if (invalidHandler) {\n this.form.addEventListener('invalid-form', (e) => {\n if (!this.isCustomEvent(e)) {\n return;\n }\n invalidHandler(e);\n });\n }\n }\n\n triggerInvalidForm(errorList: ValidationError[]) {\n const event = new CustomEvent('invalid-form', {\n detail: errorList,\n cancelable: true,\n });\n this.form.dispatchEvent(event);\n }\n\n private isCustomEvent(event: Event): event is CustomEvent {\n return 'detail' in event;\n }\n\n private handleSubmitForm(e: SubmitEvent) {\n if (this.settings.debug) {\n e.preventDefault();\n }\n\n const isValid = this.validateCallback();\n if (!isValid) {\n this.focusInvalidCallback();\n e.preventDefault();\n e.stopPropagation();\n }\n }\n\n /**\n * Removes all validation event listeners from the form\n */\n detachEventHandlers(): void {\n if (this.boundEventHandlers.onFocusIn) {\n this.form.removeEventListener(\n 'focusin',\n this.boundEventHandlers.onFocusIn,\n );\n }\n if (this.boundEventHandlers.onFocusOut) {\n this.form.removeEventListener(\n 'focusout',\n this.boundEventHandlers.onFocusOut,\n );\n }\n if (this.boundEventHandlers.onKeyUp) {\n this.form.removeEventListener('keyup', this.boundEventHandlers.onKeyUp);\n }\n if (this.boundEventHandlers.onClick) {\n this.form.removeEventListener('click', this.boundEventHandlers.onClick);\n }\n\n // Clear references\n this.boundEventHandlers.onFocusIn = null;\n this.boundEventHandlers.onFocusOut = null;\n this.boundEventHandlers.onKeyUp = null;\n this.boundEventHandlers.onClick = null;\n }\n\n /**\n * Creates a delegated event handler for the specified targets and handler\n */\n private createDelegate(\n targets: readonly string[],\n handler: ValidationEventHandler,\n ): (event: Event) => void {\n return (event: Event) => {\n let element = event.target as HTMLElement;\n if (element.tagName === 'OPTION') {\n element = element.closest('select') as HTMLElement;\n }\n\n // Skip if handler is disabled (boolean false)\n if (typeof handler === 'boolean') {\n return;\n }\n // Skip if element is null\n if (element === null) {\n return;\n }\n\n // Check if element matches any of the target selectors\n if (!element.matches(targets.join(', '))) {\n return;\n }\n\n // Ensure element belongs to the correct form\n if (!this.isElementInForm(element)) {\n return;\n }\n\n // Check if element should be ignored based on validator settings\n if (this.shouldIgnoreElement(element)) {\n return;\n }\n\n // Call the handler with the element and event\n handler(element as FormControlElement, event);\n };\n }\n\n /**\n * Checks if an element belongs to the validator's form\n */\n private isElementInForm(element: HTMLElement): boolean {\n const elementForm = (element as FormControlElement).form;\n return this.form === elementForm;\n }\n}\n","import { FormControlElement, ValidatorSettings } from './types';\nimport {\n elementValue,\n findByName,\n isBlankElement,\n isCheckableElement,\n} from './helpers';\nimport { Validator } from './validator';\n\nexport const ValidatorDefaults: ValidatorSettings = {\n ignore: ':hidden',\n errorClass: 'error',\n validClass: 'valid',\n errorElement: 'label',\n wrapper: null,\n errorLabelContainer: null,\n errorContainer: null,\n onfocusin: onFocusIn,\n onfocusout: onFocusOut,\n onkeyup: onKeyUp,\n onclick: onClick,\n highlight: highlight,\n unhighlight: unhighlight,\n errorPlacement: null,\n focusCleanup: false,\n rules: {},\n messages: {},\n escapeHtml: false,\n showErrors: null,\n ignoreTitle: false,\n success: null,\n onsubmit: true,\n debug: false,\n invalidHandler: null,\n};\n\nfunction onFocusIn(this: Validator, element: FormControlElement): void {\n this.lastActive = element;\n\n if (this.settings.focusCleanup) {\n if (typeof this.settings.unhighlight !== 'boolean') {\n this.settings.unhighlight(element, this.errorClasses, this.validClasses);\n }\n this.hideErrors(element);\n }\n}\n\nfunction onFocusOut(this: Validator, element: FormControlElement): void {\n if (isCheckableElement(element)) {\n return;\n }\n if (\n !(element.name in this.submitted) &&\n isBlankElement(element, this.currentForm)\n ) {\n return;\n }\n\n this.element(element);\n}\n\nfunction onKeyUp(\n this: Validator,\n element: FormControlElement,\n event: Event,\n): void {\n const keyboardEvent = event as KeyboardEvent;\n if (\n keyboardEvent.which === 9 &&\n elementValue(element, this.currentForm) === ''\n ) {\n return;\n }\n\n // Avoid revalidate the field when pressing one of the following keys\n // Shift => 16\n // Ctrl => 17\n // Alt => 18\n // Caps lock => 20\n // End => 35\n // Home => 36\n // Left arrow => 37\n // Up arrow => 38\n // Right arrow => 39\n // Down arrow => 40\n // Insert => 45\n // Num lock => 144\n // AltGr key => 225\n const excludedKeys = [16, 17, 18, 20, 35, 36, 37, 38, 39, 40, 45, 144, 225];\n if (excludedKeys.includes(keyboardEvent.keyCode)) {\n return;\n }\n\n if (!(element.name in this.submitted) && !(element.name in this.invalid)) {\n return;\n }\n\n this.element(element);\n}\n\nfunction onClick(this: Validator, element: FormControlElement): void {\n // Click on selects, radiobuttons and checkboxes\n if (element.name in this.submitted) {\n this.element(element);\n }\n // Or option elements, check parent select in that case\n else if (element.parentNode && element.parentElement) {\n const name = element.parentElement.getAttribute('name');\n\n if (name && name in this.submitted) {\n this.element(element.parentNode as FormControlElement);\n }\n }\n}\n\nfunction highlight(\n this: Validator,\n element: FormControlElement,\n errorClasses: string[],\n validClasses: string[],\n): void {\n let targets = [element];\n if (element.type === 'radio') {\n targets = findByName(this.currentForm, element.name);\n }\n\n targets.forEach((el) => {\n el.classList.add(...errorClasses);\n el.classList.remove(...validClasses);\n });\n}\n\nfunction unhighlight(\n this: Validator,\n element: FormControlElement,\n errorClasses: string[],\n validClasses: string[],\n): void {\n let targets = [element];\n if (element.type === 'radio') {\n targets = findByName(this.currentForm, element.name);\n }\n\n targets.forEach((el) => {\n el.classList.remove(...errorClasses);\n el.classList.add(...validClasses);\n });\n}\n","import {\n elementValue,\n escapeCssMeta,\n findByName,\n getValueLength,\n hideElement,\n idOrName,\n isBlankElement,\n isCheckableElement,\n isVisible,\n objectLength,\n showElement,\n} from './helpers';\nimport { getRules, normalizeRule } from './rules';\nimport { getMessage } from './messages';\nimport { validatorStore } from './validatorStore';\nimport { store as methodStore } from './methods';\nimport { FormEventManager } from './eventManager';\nimport {\n FormControlElement,\n ValidationError,\n ValidationRuleset,\n ValidatorSettings,\n} from './types';\nimport { ValidatorDefaults } from './defaults';\n\nexport class Validator {\n currentForm: HTMLFormElement;\n errorContext!: HTMLElement;\n submitted: Record<string, string> = {};\n invalid: Record<string, string> = {};\n successList: FormControlElement[] = [];\n errorList: ValidationError[] = [];\n errorMap: Record<string, string> = {};\n toShow: HTMLElement[] = [];\n toHide: HTMLElement[] = [];\n currentElements: FormControlElement[] = [];\n labelContainer: HTMLElement | null = null;\n containers: HTMLElement[] = [];\n lastActive: FormControlElement | null = null;\n\n /** normalized rules */\n rules: Record<string, ValidationRuleset> = {};\n\n /** event delegation manager */\n private eventManager!: FormEventManager;\n\n settings: ValidatorSettings = ValidatorDefaults;\n\n /**\n * Initializes a new validator instance for the given form with optional configuration settings.\n * @param form - form element to validate\n * @param options - optional user configuration settings\n */\n constructor(form: HTMLFormElement, options?: Partial<ValidatorSettings>) {\n this.currentForm = form;\n this.settings = { ...this.settings, ...options };\n\n this.normalizeSettings();\n this.init();\n }\n\n /**\n * Normalizes Validator settings.\n * Currently, this only binds function settings to validator instance.\n */\n normalizeSettings(): void {\n // bind function settings to this validator instance\n [\n 'onfocusin',\n 'onfocusout',\n 'onkeyup',\n 'onclick',\n 'highlight',\n 'unhighlight',\n 'errorPlacement',\n 'invalidHandler',\n ].forEach((key) => {\n const setting = this.settings[key as keyof ValidatorSettings];\n if (setting && typeof setting === 'function') {\n (this.settings as any)[key] = setting.bind(this);\n }\n });\n }\n\n /**\n * Sets up DOM references and attaches event handlers to the form.\n */\n init(): void {\n if (this.settings.errorLabelContainer) {\n this.labelContainer = document.querySelector(\n this.settings.errorLabelContainer,\n );\n }\n this.errorContext = this.labelContainer || this.currentForm;\n\n const containers = [this.labelContainer];\n if (this.settings.errorContainer) {\n containers.push(document.querySelector(this.settings.errorContainer));\n }\n this.containers = containers.filter(Boolean) as HTMLElement[];\n\n this.rules = {};\n Object.entries(this.settings.rules).forEach(([key, value]) => {\n this.rules[key] = normalizeRule(value);\n });\n\n this.eventManager = new FormEventManager(\n this.currentForm,\n this.settings,\n () => this.form(),\n () => this.focusInvalid(),\n (element) => this.shouldIgnore(element),\n );\n this.eventManager.attachEventHandlers();\n }\n\n /**\n * Resets the validator state.\n */\n reset(): void {\n this.successList = [];\n this.errorList = [];\n this.errorMap = {};\n this.toShow = [];\n this.toHide = [];\n this.currentElements = [];\n }\n\n /**\n * Validates all form elements.\n * @return true if the form is valid, false otherwise\n */\n form(): boolean {\n this.prepareForm();\n this.currentElements = this.elements();\n for (const element of this.currentElements) {\n this.check(element);\n }\n\n this.submitted = { ...this.submitted, ...this.errorMap };\n this.invalid = { ...this.errorMap };\n if (!this.valid()) {\n this.eventManager.triggerInvalidForm(this.errorList);\n }\n this.showErrors();\n return this.valid();\n }\n\n /**\n * Validates a single element within the form.\n * @param element - element to validate\n * @return true if the element is valid, false otherwise\n */\n element(element: FormControlElement): boolean {\n const target = this.validationTargetFor(element);\n if (target === undefined) {\n delete this.invalid[element.name];\n return true;\n }\n\n this.prepareElement(target);\n this.currentElements = [target];\n\n const result = this.check(target);\n if (result) {\n delete this.invalid[element.name];\n } else {\n this.invalid[target.name] = 'Invalid';\n }\n\n if (!this.numberOfInvalids()) {\n this.toHide.push(...this.containers);\n }\n this.showErrors();\n\n // add aria-invalid status for screen readers\n element.setAttribute('aria-invalid', (!result).toString());\n\n return result;\n }\n\n prepareElement(element: FormControlElement): void {\n this.reset();\n this.toHide = this.errorsFor(element);\n }\n\n /**\n * Returns true if there are currently no validation errors.\n * @return {boolean} - true if there are no validation errors, false otherwise\n */\n valid(): boolean {\n return this.size() === 0;\n }\n\n /**\n * Returns the number of validation errors.\n * @return number of validation errors\n */\n size(): number {\n return this.errorList.length;\n }\n\n /**\n * Returns a list of all form elements that need to be validated.\n * @return list of form elements\n */\n elements(): FormControlElement[] {\n const rulesCache: Record<string, boolean> = {};\n\n const selector = 'input, select, textarea';\n const notSelector =\n 'input[type=\"submit\"], [type=\"reset\"], [type=\"image\"], [disabled]';\n\n const elements = (\n Array.from(this.currentForm.querySelectorAll(selector)) as HTMLElement[]\n ).filter(\n (el) => !el.matches(notSelector) && !this.shouldIgnore(el),\n ) as FormControlElement[];\n\n const formId = this.currentForm.id;\n if (formId) {\n const escapedId = escapeCssMeta(formId);\n\n const outsideElements = (\n Array.from(document.querySelectorAll(selector)) as HTMLElement[]\n ).filter(\n (el) =>\n el.matches(`[form=\"${escapedId}\"]`) &&\n !el.matches(notSelector) &&\n !this.shouldIgnore(el),\n ) as FormControlElement[];\n\n elements.push(...outsideElements);\n }\n\n return elements.filter((el) => {\n const form = el.form;\n if (form !== this.currentForm) {\n return false;\n }\n\n const name = el.name || el.getAttribute('name');\n if (\n !name ||\n name in rulesCache ||\n !objectLength(getRules(el, this.rules))\n ) {\n return false;\n }\n\n rulesCache[name] = true;\n return true;\n });\n }\n\n /**\n * Returns an array of currently valid elements from the last validation.\n * @return list of valid form elements\n */\n validElements(): FormControlElement[] {\n const invalid = this.invalidElements();\n return this.currentElements.filter((el) => !invalid.includes(el));\n }\n\n /**\n * Returns an array of currently invalid elements from the last validation.\n * @return list of invalid form elements\n */\n invalidElements(): FormControlElement[] {\n return this.errorList.map((e) => e.element);\n }\n\n /**\n * Runs all validation rules against an element and returns true if valid.\n * @param element - element to validate\n * @return true if the element is valid, false otherwise\n */\n check(element: FormControlElement): boolean {\n element = this.validationTargetFor(element);\n\n const rules = getRules(element, this.rules);\n const elValue = elementValue(element, this.currentForm);\n\n const value = (Array.isArray(elValue) ? elValue[0] : elValue) ?? '';\n const values = Array.isArray(elValue) ? elValue : [elValue];\n\n const length = getValueLength(element, this.currentForm);\n const blank = isBlankElement(element, this.currentForm);\n\n for (const method in rules) {\n const rule = { method, parameters: rules[method]! };\n\n const methodFunc = methodStore.get(method);\n if (!methodFunc) {\n console.warn(`Validation method \"${method}\" not found. Skipping.`);\n continue;\n }\n\n try {\n const result = methodFunc({\n blank,\n value: value,\n values,\n length,\n element,\n param: rule.parameters,\n });\n\n if (!result) {\n this.formatAndAdd(element, rule);\n return false;\n }\n } catch (e) {\n throw e;\n }\n }\n\n if (objectLength(rules)) {\n this.successList.push(element);\n }\n return true;\n }\n\n /**\n * Returns all error label elements currently in the DOM.\n * @return array of error label elements\n */\n errors(): HTMLElement[] {\n const errorClass = this.errorClasses.join('.');\n return Array.from(\n this.errorContext.querySelectorAll(\n `${this.settings.errorElement}.${errorClass}`,\n ),\n );\n }\n\n showErrors(errors?: Record<string, string>) {\n if (errors) {\n // Add items to error list and map\n this.errorMap = { ...this.errorMap, ...errors };\n this.errorList = Object.entries(this.errorMap).map(([name, message]) => ({\n message,\n method: message,\n element: findByName(this.currentForm, name)[0]!,\n }));\n\n // Remove items from success list\n this.successList = this.successList.filter((e) => !(e.name in errors));\n }\n\n if (this.settings.showErrors) {\n return this.settings.showErrors.call(this, this.errorMap, this.errorList);\n }\n\n return this.defaultShowErrors();\n }\n\n defaultShowErrors(): void {\n for (const error of this.errorList) {\n if (this.settings.highlight) {\n this.settings.highlight(\n error.element,\n this.errorClasses,\n this.validClasses,\n );\n }\n this.showLabel(error.element, error.message);\n }\n\n if (this.errorList.length) {\n this.toShow = this.toShow.concat(this.containers);\n }\n\n if (this.settings.success) {\n for (const element of this.successList) {\n this.showLabel(element);\n }\n }\n\n if (this.settings.unhighlight) {\n for (const element of this.validElements()) {\n this.settings.unhighlight(\n element,\n this.errorClasses,\n this.validClasses,\n );\n }\n }\n\n this.toHide = this.toHide.filter((el) => !this.toShow.includes(el));\n this.hideErrors();\n this.addWrapper(...this.toShow).forEach(showElement);\n }\n\n formatAndAdd(\n element: FormControlElement,\n rule: { method: string; parameters: any },\n ): void {\n const message = this.getMessage(element, rule);\n\n this.errorList.push({ message, element, method: rule.method });\n this.errorMap[element.name] = message;\n this.submitted[element.name] = message;\n }\n\n prepareForm(): void {\n this.reset();\n this.toHide = this.errors().concat(this.containers);\n }\n\n hideErrors(element?: FormControlElement): void {\n // we're either hiding all errors, or just the errors for a specific element\n let targets = this.toHide;\n if (element) {\n targets = this.errorsFor(element);\n }\n\n for (const el of targets) {\n if (!this.containers.includes(el)) {\n el.innerText = '';\n }\n\n this.addWrapper(el).forEach(hideElement);\n }\n }\n\n addWrapper(...elements: HTMLElement[]): HTMLElement[] {\n const result = Array.isArray(elements) ? elements : [elements];\n\n if (!this.settings.wrapper) {\n return result;\n }\n\n const wrappers = result\n .map((el) => el.parentElement)\n .filter((el) => el && el.matches(this.settings.wrapper!));\n\n result.push(...(wrappers as HTMLElement[]));\n\n return result;\n }\n\n showLabel(element: FormControlElement, message?: string): void {\n let errors = this.errorsFor(element);\n const elementID = idOrName(element);\n const describedBy = element.getAttribute('aria-describedby');\n\n if (errors.length) {\n // Non-label error exists but is not currently associated with element via aria-describedby\n const labelSelector = `label[for='${escapeCssMeta(elementID)}']`;\n const nonLabelExists = errors\n .map((e) => e.closest(labelSelector))\n .every((e) => e === null);\n\n const noDescriberAssociation = () => {\n if (describedBy === null) {\n return true;\n }\n const firstErrorId = errors[0]?.getAttribute('id') ?? null;\n if (firstErrorId === null) {\n return true;\n }\n\n const split = describedBy.split(' ');\n return split.indexOf(firstErrorId) === -1;\n };\n\n if (nonLabelExists && noDescriberAssociation()) {\n const firstErrorId = errors[0]!.getAttribute('id')!;\n this.addErrorAriaDescribedBy(element, firstErrorId);\n }\n\n // Refresh error/success class\n errors.forEach((el) => {\n el.classList.remove(this.settings.validClass);\n el.classList.add(...this.errorClasses);\n if (this.settings.escapeHtml) {\n el.innerText = message || '';\n } else {\n el.innerHTML = message || '';\n }\n });\n } else {\n const newError = document.createElement(this.settings.errorElement);\n newError.setAttribute('id', `${elementID}-error`);\n newError.classList.add(...this.errorClasses);\n if (this.settings.escapeHtml) {\n newError.innerText = message || '';\n } else {\n newError.innerHTML = message || '';\n }\n\n // Maintain reference to the element(s) to be placed into the DOM\n let insert = newError;\n if (this.settings.wrapper) {\n const wrapper = document.createElement(this.settings.wrapper);\n wrapper.appendChild(newError);\n insert = wrapper;\n }\n\n if (this.labelContainer) {\n this.labelContainer.appendChild(insert);\n } else if (element.dataset.errorPlacement) {\n const target = document.querySelector(element.dataset.errorPlacement);\n if (target) {\n target.appendChild(insert);\n } else {\n console.warn(\n `dv: data-error-placement target \"${element.dataset.errorPlacement}\" not found, using default placement`,\n );\n element.after(insert);\n }\n } else if (this.settings.errorPlacement) {\n this.settings.errorPlacement(insert, element);\n } else {\n element.after(insert);\n }\n\n // Link error back to the element\n if (newError.matches('label')) {\n // If the error is a label, then associate using 'for'\n newError.setAttribute('for', elementID);\n }\n // If the element is not a child of an associated label, then it's necessary\n // to explicitly apply aria-describedby\n else if (\n !newError.parentElement?.matches(\n `label[for='${escapeCssMeta(elementID)}']`,\n )\n ) {\n this.addErrorAriaDescribedBy(element, newError.getAttribute('id')!);\n }\n\n errors = [newError];\n }\n\n if (!message && this.settings.success) {\n errors.forEach((e) => (e.innerText = ''));\n\n const successSetting = this.settings.success;\n if (typeof successSetting === 'string') {\n errors.forEach((e) => e.classList.add(successSetting));\n } else {\n successSetting(errors, element);\n }\n }\n\n this.toShow.push(...errors);\n }\n\n addErrorAriaDescribedBy(element: FormControlElement, errorId: string) {\n let describedBy = element.getAttribute('aria-describedby');\n\n if (!describedBy) {\n describedBy = errorId;\n } else if (\n !describedBy.match(new RegExp(`\\\\b${escapeCssMeta(errorId)}\\\\b`))\n ) {\n describedBy += ` ${errorId}`;\n }\n\n element.setAttribute('aria-describedby', describedBy);\n }\n\n errorsFor(element: FormControlElement): HTMLElement[] {\n const name = escapeCssMeta(idOrName(element));\n const describer = element.getAttribute('aria-describedby');\n\n let selector = `label[for='${name}'], label[for='${name}'] *`;\n if (describer) {\n const escapedDescriber = escapeCssMeta(describer).replace(/\\s+/g, ', #');\n selector += `, #${escapedDescriber}`;\n }\n\n return this.errors().filter((el) => el.matches(selector));\n }\n\n numberOfInvalids(): number {\n return objectLength(this.invalid);\n }\n\n destroy(): void {\n this.resetForm();\n validatorStore.delete(this.currentForm);\n this.eventManager.detachEventHandlers();\n }\n\n resetForm(): void {\n this.invalid = {};\n this.submitted = {};\n this.prepareForm();\n this.hideErrors();\n\n this.elements().forEach((el) => el.removeAttribute('aria-invalid'));\n this.resetElements();\n }\n\n resetElements(): void {\n if (this.settings.unhighlight) {\n for (const element of this.elements()) {\n this.settings.unhighlight(element, this.errorClasses, []);\n findByName(this.currentForm, element.name).forEach((el) =>\n el.classList.remove(...this.validClasses),\n );\n }\n } else {\n this.elements().forEach((el) => {\n el.classList.remove(...this.errorClasses);\n el.classList.remove(...this.validClasses);\n });\n }\n }\n\n validationTargetFor(element: FormControlElement): FormControlElement {\n let targets = [element];\n if (isCheckableElement(element)) {\n targets = findByName(this.currentForm, element.name);\n }\n\n return targets.filter((t) => !this.shouldIgnore(t))[0]!;\n }\n\n /**\n * Returns true if the element should be skipped from receiving validation.\n * @param element - element to check\n * @return true if the element should be skipped, false otherwise\n */\n shouldIgnore(element: HTMLElement): boolean {\n if (!this.settings.ignore) {\n return false;\n }\n if (this.settings.ignore === ':hidden') {\n return !isVisible(element);\n }\n\n return element.matches(this.settings.ignore);\n }\n\n getMessage(\n element: FormControlElement,\n rule: string | { method: string; parameters?: any },\n ) {\n if (typeof rule === 'string') {\n rule = { method: rule };\n }\n\n let customMessage: string | undefined;\n const msgSettings = this.settings.messages[element.name];\n if (msgSettings && typeof msgSettings === 'string') {\n customMessage = msgSettings;\n } else if (msgSettings && typeof msgSettings === 'object') {\n customMessage = msgSettings[rule.method];\n }\n\n return getMessage.call(\n this,\n element,\n rule,\n this.settings.ignoreTitle,\n customMessage,\n );\n }\n\n focusInvalid(): void {\n const lastActive = this.findLastActive();\n const firstErrorElement = this.errorList.length\n ? this.errorList[0]!.element\n : null;\n\n const el = lastActive || firstErrorElement;\n if (!el || !isVisible(el)) {\n return;\n }\n\n // Focus the element\n el.focus();\n\n // Manually dispatch \"focusin\"\n const focusInEvent = new Event('focusin', { bubbles: true });\n el.dispatchEvent(focusInEvent);\n }\n\n findLastActive() {\n const lastActive = this.lastActive;\n if (!lastActive) return;\n\n const matches = this.errorList.filter(\n (n) => n.element.name === lastActive.name,\n );\n\n return matches.length === 1 ? lastActive : undefined;\n }\n\n get errorClasses(): string[] {\n return this.settings.errorClass.split(' ').filter(Boolean);\n }\n\n get validClasses(): string[] {\n return this.settings.validClass.split(' ').filter(Boolean);\n }\n}\n","/**\n * @fileoverview Core validation library for client-side form validation.\n * Provides programmatic API for validating forms and form elements.\n */\n\nimport { Validator } from './validator';\nimport { validatorStore } from './validatorStore';\nimport { addClassRule, getRules } from './rules';\nimport { store as methods } from './methods';\nimport { store as messages } from './messages';\nimport {\n FormControlElement,\n ValidationError,\n ValidationMethod,\n ValidationRuleset,\n ValidatorSettings,\n} from './types';\n\n/**\n * Creates or retrieves a validator for a form or form element.\n * If a validator already exists for the element, returns the existing validator.\n *\n * @param selector - CSS selector string or HTMLElement to validate\n * @param [options] - Validation options including rules, messages, and callbacks\n * @returns Validator instance or undefined if element not found\n * @example\n * // Validate a form with rules\n * dv.validate('#myForm', {\n * rules: {\n * email: { required: true, email: true },\n * password: { required: true, minlength: 8 }\n * }\n * });\n */\nexport function validate(\n selector: string | Element | null,\n options?: Partial<ValidatorSettings>,\n): Validator | undefined {\n if (!selector) {\n console.warn(\"No element selected, can't validate.\");\n return;\n }\n\n const element =\n selector instanceof Element ? selector : document.querySelector(selector);\n\n if (!element) {\n console.warn(\"No element selected, can't validate.\");\n return;\n }\n if (!(element instanceof HTMLFormElement)) {\n const elementType = element.tagName || 'unknown element';\n console.warn(\n `Element must be a form element for validation. Received: ${elementType}`,\n );\n return;\n }\n\n if (validatorStore.has(element)) {\n return validatorStore.get(element);\n }\n\n const validator = new Validator(element, options);\n validatorStore.set(element, validator);\n return validator;\n}\n\n/**\n * Validates form or form elements and returns whether they are valid.\n * Triggers validation and returns the result without submitting the form.\n *\n * @param selector - Element(s) to validate:\n * CSS selector, element, or array of elements\n * @returns True if all elements are valid, false otherwise\n * @example\n * // Check if form is valid\n * if (dv.valid('#myForm')) {\n * console.log('Form is valid!');\n * }\n *\n * // Check specific fields\n * if (dv.valid(['#email', '#password'])) {\n * console.log('Email and password are valid!');\n * }\n */\nexport function valid(selector: string | HTMLElement | HTMLElement[]): boolean {\n let elements: any[] = [];\n if (typeof selector === 'string') {\n elements = Array.from(document.querySelectorAll(selector));\n } else if (selector instanceof HTMLElement) {\n elements = [selector];\n } else if (Array.isArray(selector)) {\n elements = selector;\n }\n\n if (elements[0].matches('form')) {\n return validate(elements[0])?.form() ?? false;\n }\n\n const errorList: ValidationError[] = [];\n let valid = true;\n const validator = validate(elements[0].form);\n if (!validator) {\n return false;\n }\n\n elements.forEach((el) => {\n valid = validator.element(el) && valid;\n if (!valid) {\n errorList.push(...validator.errorList);\n }\n });\n\n validator.errorList = errorList;\n return valid;\n}\n\n/**\n * Gets the validation rules for an element.\n *\n * @param selector - CSS selector string or HTMLElement\n * @returns Object containing validation rules for the element\n * @example\n * // Get rules for an input\n * const emailRules = dv.rules('#email');\n * console.log(emailRules); // { required: true, email: true }\n */\nexport function rules(selector: string | HTMLElement): ValidationRuleset {\n const element =\n selector instanceof HTMLElement\n ? selector\n : document.querySelector(selector);\n\n const validator = validate((element as any).form);\n if (!validator) {\n return {};\n }\n\n return getRules(element as FormControlElement, validator.rules);\n}\n\n/**\n * Adds a custom validation method.\n * The method can be used in validation rules by its name.\n *\n * @param name - Name of the validation method\n * @param method - Validation function that returns true if valid\n * @param message - Default error message for this validation method\n * @example\n * // Add a custom phone validation method\n * dv.addMethod('phone', function(blank, value, element) {\n * return blank || /^\\d{3}-\\d{3}-\\d{4}$/.test(value);\n * }, 'Please enter a valid phone number (xxx-xxx-xxxx)');\n *\n * // Use in validation rules\n * dv.validate('#myForm', {\n * rules: {\n * phoneNumber: { phone: true }\n * }\n * });\n */\nexport function addMethod(\n name: string,\n method: ValidationMethod,\n message?: any,\n) {\n methods.set(name, method);\n if (message) {\n messages.set(name, message);\n }\n if (method.length < 3) {\n addClassRule(name);\n }\n}\n\n/**\n * Replaces default error messages or validation methods with localized versions.\n *\n * @param data - Object containing either localized error messages (string values) or\n * validation methods (function values). If values are strings, replaces\n * error messages. If values are functions, replaces validation methods.\n *\n * @example\n * // Localize error messages to French\n * dv.localize({\n * required: 'Ce champ est obligatoire.',\n * email: 'Veuillez entrer une adresse email valide.',\n * minlength: 'Veuillez entrer au moins {0} caractères.'\n * });\n */\nexport function localize(\n data: Record<string, string> | Record<string, ValidationMethod>,\n) {\n const firstValue = Object.values(data)[0];\n\n if (typeof firstValue === 'string') {\n messages.replace(data as Record<string, string>);\n } else {\n methods.replace(data as Record<string, ValidationMethod>);\n }\n}\n\n/**\n * Map of validation error messages.\n */\nexport { messages };\n\n/**\n * Map of validation methods.\n */\nexport { methods };\n\n/**\n * Default export containing all validation functions and stores.\n * @namespace\n */\nexport default {\n validate,\n valid,\n rules,\n addMethod,\n localize,\n messages,\n methods,\n};\n"],"names":["isVisible","el","offsetWidth","offsetHeight","getClientRects","length","objectLength","obj","count","key","undefined","findByName","form","name","selector","escapeCssMeta","elements","Array","from","querySelectorAll","id","outsideElements","document","filter","matches","push","isCheckableElement","element","test","type","text","replace","elementValue","map","value","validity","badInput","substring","idx","lastIndexOf","fileInputValue","formatString","source","params","isArray","forEach","param","index","RegExp","String","idOrName","getValueLength","nodeName","toLowerCase","isBlankElement","selectedOptions","selected","o","displayDataMap","WeakMap","showElement","storedDisplay","get","style","display","delete","hideElement","set","getComputedStyle","ObjectStore","constructor","data","this","_store","keys","Object","entries","store","required","blank","minlength","maxlength","rangelength","min","max","range","email","url","date","Date","toString","dateISO","number","digits","equalTo","target","querySelector","regex","match","exec","nonalphamin","creditcard","strippedValue","nCheck","bEven","n","cDigit","charAt","nDigit","parseInt","getRules","settings","rules","ruleKey","Number","parts","split","normalizeRules","assign","classes","getAttribute","className","classRuleSettings","classRules","method","methodStore","normalizeAttributeRule","attributeRules","datasetKey","toUpperCase","_a","dataset","dataRules","normalizeRule","staticRules","transformed","token","getMessage","rule","ignoreTitle","customMessage","message","customDataMessage","title","find","x","parameters","args","dataSetKey","validatorStore","EVENT_TARGETS","FormEventManager","validateCallback","focusInvalidCallback","shouldIgnoreElement","boundEventHandlers","onFocusIn","onFocusOut","onKeyUp","onClick","attachEventHandlers","createDelegate","onfocusin","onfocusout","onkeyup","onclick","addEventListener","onsubmit","e","handleSubmitForm","invalidHandler","isCustomEvent","triggerInvalidForm","errorList","event","CustomEvent","detail","cancelable","dispatchEvent","debug","preventDefault","stopPropagation","detachEventHandlers","removeEventListener","targets","handler","tagName","closest","join","isElementInForm","elementForm","ValidatorDefaults","ignore","errorClass","validClass","errorElement","wrapper","errorLabelContainer","errorContainer","lastActive","focusCleanup","unhighlight","errorClasses","validClasses","hideErrors","submitted","currentForm","keyboardEvent","which","includes","keyCode","invalid","parentNode","parentElement","highlight","classList","add","remove","errorPlacement","messages","escapeHtml","showErrors","success","Validator","options","successList","errorMap","toShow","toHide","currentElements","labelContainer","containers","normalizeSettings","init","setting","bind","errorContext","Boolean","eventManager","focusInvalid","shouldIgnore","reset","prepareForm","check","valid","validationTargetFor","prepareElement","result","numberOfInvalids","setAttribute","errorsFor","size","rulesCache","notSelector","formId","escapedId","validElements","invalidElements","elValue","values","methodFunc","formatAndAdd","console","warn","errors","call","defaultShowErrors","error","showLabel","concat","addWrapper","innerText","wrappers","elementID","describedBy","labelSelector","noDescriberAssociation","firstErrorId","_b","indexOf","every","addErrorAriaDescribedBy","innerHTML","newError","createElement","insert","appendChild","after","successSetting","errorId","describer","escapedDescriber","destroy","resetForm","removeAttribute","resetElements","t","msgSettings","findLastActive","firstErrorElement","focus","focusInEvent","Event","bubbles","validate","Element","HTMLFormElement","elementType","has","validator","HTMLElement","addMethod","methods","localize"],"mappings":";;;;;;;;;;yOAOM,SAAUA,EAAUC,GACxB,SAAUA,EAAGC,aAAeD,EAAGE,cAAgBF,EAAGG,iBAAiBC,OACrE,CAOM,SAAUC,EAAaC,GAC3B,IAAIC,EAAQ,EACZ,IAAK,MAAMC,KAAOF,OAECG,IAAbH,EAAIE,IAAmC,OAAbF,EAAIE,KAA8B,IAAbF,EAAIE,IACrDD,IAGJ,OAAOA,CACT,CAQM,SAAUG,EACdC,EACAC,GAEA,MAAMC,EAAW,UAAUC,EAAcF,OAEnCG,EAAWC,MAAMC,KAAKN,EAAKO,iBAAiBL,IAElD,GAAIF,EAAKQ,GAAI,CACX,MAAMC,EAAkBJ,MAAMC,KAC5BI,SAASH,iBAAiBL,IAC1BS,OAAQtB,GAAOA,EAAGuB,QAAQ,UAAUT,EAAcH,EAAKQ,UACzDJ,EAASS,QAAQJ,EACnB,CAEA,OAAOL,CACT,CAOM,SAAUU,EAAmBC,GACjC,MAAO,kBAAkBC,KAAKD,EAAQE,MAAQ,GAChD,CAQM,SAAUd,EAAce,GAC5B,YAAapB,IAAToB,EACK,GAGFA,EAAKC,QAAQ,yCAA0C,OAChE,CAQM,SAAUC,EACdL,EACAf,GAEA,GAAqB,UAAjBe,E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AAMa,EACJb,aAAoBwS,YAChBxS,EACAQ,SAAS0E,cAAclF,GAEvBuS,EAAYL,EAAUrR,EAAgBf,MAC5C,OAAKyS,EAIEvM,EAASnF,EAA+B0R,EAAUrM,OAHhD,CAAA,CAIX,UAsBgBuM,EACd1S,EACA+G,EACAiB,GN7GI,IAAuBpB,EM+G3B+L,EAAQrP,IAAItD,EAAM+G,GACdiB,GACF8E,EAASxJ,IAAItD,EAAMgI,GAEjBjB,EAAOvH,OAAS,INlHpBqH,EAD2BD,EMoHZ5G,GNnHgBwH,EAAcZ,GMqH/C,CAiBM,SAAUgM,EACdlP,GAI0B,iBAFPI,OAAOwL,OAAO5L,GAAM,GAGrCoJ,EAAS5L,QAAQwC,GAEjBiP,EAAQzR,QAAQwC,EAEpB,CAgBA,IAAAxB,EAAe,CACbiQ,WACA5D,QACApI,QACAuM,YACAE,oBACA9F,UACA6F"}
1
+ {"version":3,"file":"dv.min.js","sources":["../src/helpers.ts","../src/objectStore.ts","../src/methods.ts","../src/rules.ts","../src/messages.ts","../src/validatorStore.ts","../src/eventManager.ts","../src/defaults.ts","../src/validator.ts","../src/index.ts"],"sourcesContent":["import { FormControlElement } from './types';\n\n/**\n * Returns true if the element is visible in the DOM.\n * @param el - element to check visibility\n * @return true if element is visible, false otherwise\n */\nexport function isVisible(el: HTMLElement): boolean {\n return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);\n}\n\n/**\n * Returns the number of truthy properties in an object.\n * @param obj - object to count properties\n * @return count of truthy properties\n */\nexport function objectLength(obj: any): number {\n let count = 0;\n for (const key in obj) {\n // This check allows counting elements with empty error message as invalid elements\n if (obj[key] !== undefined && obj[key] !== null && obj[key] !== false) {\n count++;\n }\n }\n return count;\n}\n\n/**\n * Finds all form elements with the specified name attribute.\n * @param form - form element to search within\n * @param name - name attribute to search for\n * @return array of matching elements\n */\nexport function findByName(\n form: HTMLFormElement,\n name: string,\n): FormControlElement[] {\n const selector = `[name='${escapeCssMeta(name)}']`;\n\n const elements = Array.from(form.querySelectorAll(selector));\n\n // getAttribute: a field named \"id\" shadows form.id\n const formId = form.getAttribute('id');\n if (formId) {\n const outsideElements = Array.from(\n document.querySelectorAll(selector),\n ).filter((el) => el.matches(`[form=\"${escapeCssMeta(formId)}\"]`));\n elements.push(...outsideElements);\n }\n\n return elements as FormControlElement[];\n}\n\n/**\n * Returns true if the element is a radio button or checkbox.\n * @param element - element to check\n * @return true if element is radio or checkbox, false otherwise\n */\nexport function isCheckableElement(element: FormControlElement): boolean {\n return /radio|checkbox/i.test(element.type || '');\n}\n\n/**\n * Escapes CSS meta-characters in a string for use in CSS selectors.\n * See https://api.jquery.com/category/selectors/ for CSS meta-characters that should be escaped.\n * @param text - text to escape\n * @return escaped text safe for CSS selectors\n */\nexport function escapeCssMeta(text: string): string {\n if (text === undefined) {\n return '';\n }\n\n return text.replace(/([\\\\!\"#$%&'()*+,./:;<=>?@\\[\\]^`{|}~])/g, '\\\\$1');\n}\n\n/**\n * Gets the value of a form element, handling special cases for different input types.\n * @param element - form control element to get value of\n * @param form - current html form being validated\n * @return element value or array of values for checkboxes/radios\n */\nexport function elementValue(\n element: FormControlElement,\n form: HTMLFormElement,\n): string | string[] {\n if (element.type === 'radio' || element.type === 'checkbox') {\n const checked = findByName(form, element.name).filter((el) =>\n el.matches(':checked'),\n );\n return checked.map((el) => el.value);\n }\n if (element.type === 'number' && typeof element.validity !== 'undefined') {\n return element.validity.badInput ? 'NaN' : element.value;\n }\n if (element.type === 'file') {\n return fileInputValue(element);\n }\n\n return element.value.replace(/\\r/g, '');\n}\n\n/**\n * Get the value of a file input element.\n * @param element - file input element\n * @return file path or file name\n */\nexport function fileInputValue(element: FormControlElement): string {\n const value = element.value;\n\n // Modern browser (chrome & safari)\n if (value.substring(0, 12) === 'C:\\\\fakepath\\\\') {\n return value.substring(12);\n }\n\n // Legacy browsers\n // Unix-based path\n let idx = value.lastIndexOf('/');\n if (idx >= 0) {\n return value.substring(idx + 1);\n }\n\n // Windows-based path\n idx = value.lastIndexOf('\\\\');\n if (idx >= 0) {\n return value.substring(idx + 1);\n }\n\n // Just the file name\n return value;\n}\n\n/**\n * Formats a string by replacing {0}, {1}, etc. placeholders with provided parameters.\n * @param source - template string with placeholders\n * @param params - parameters to substitute into placeholders\n * @return formatted string or curried function if only source provided\n */\nexport function format(\n source: string,\n params?: any,\n): ((...args: any[]) => string) | string {\n // If no params provided, return a curried function\n if (params === undefined) {\n return function (args: any[]) {\n return formatString(source, args);\n };\n }\n\n if (!Array.isArray(params)) {\n params = [params];\n }\n\n return formatString(source, params);\n}\n\n/**\n * Internal helper to format a string with parameters.\n * @param source - template string with placeholders\n * @param params - parameters to substitute\n * @return formatted string\n */\nfunction formatString(source: string, params: any[]): string {\n if (!Array.isArray(params)) {\n params = [params];\n }\n\n params.forEach((param: any, index: number) => {\n // a replacement function: $&, $' and $` in the parameter stay as they are\n source = source.replace(new RegExp(`\\\\{${index}\\\\}`, 'g'), () =>\n String(param),\n );\n });\n\n return source;\n}\n\n/**\n * Returns the id or name attribute of an element, preferring name for checkable elements.\n * @param element - element to get identifier from\n * @return element id or name\n */\nexport function idOrName(element: FormControlElement): string {\n return (\n (isCheckableElement(element) ? element.name : element.id) || element.name\n );\n}\n\n/**\n * Gets the length of a form element's value, handling special cases for selects and checkables.\n * @param element - form control element\n * @param form - html form element\n * @return length of the element's value\n */\nexport function getValueLength(\n element: FormControlElement,\n form: HTMLFormElement,\n): number {\n const nodeName = element.nodeName.toLowerCase();\n const value = elementValue(element, form);\n\n if (nodeName === 'select') {\n return element.querySelectorAll('option:checked').length;\n } else if (nodeName === 'input' && isCheckableElement(element)) {\n return findByName(form, element.name).filter((el) => el.matches(':checked'))\n .length;\n }\n\n return value.length;\n}\n\n/**\n * Returns true if the element has no value or is considered blank.\n * @param element - form control element to check\n * @param form - current form element\n * @return true if element is blank, false otherwise\n */\nexport function isBlankElement(\n element: FormControlElement,\n form: HTMLFormElement,\n): boolean {\n const value = elementValue(element, form);\n\n if (element.nodeName.toLowerCase() === 'select' && element.selectedOptions) {\n const selected = Array.from(element.selectedOptions).map((o) => o.value);\n\n return selected.length === 0 || !selected[0];\n }\n\n if (isCheckableElement(element)) {\n return getValueLength(element, form) === 0;\n }\n\n return value === undefined || value === null || value.length === 0;\n}\n\nconst displayDataMap = new WeakMap();\n\n/**\n * Shows an element by restoring its original display value.\n * Matches jQuery's .show() behavior.\n * @param element - Element to show\n */\nexport function showElement(element: HTMLElement): void {\n const storedDisplay = displayDataMap.get(element);\n if (storedDisplay) {\n element.style.display = storedDisplay;\n displayDataMap.delete(element);\n } else {\n element.style.display = '';\n }\n}\n\n/**\n * Hides an element by setting display to none, storing the original display value.\n * Matches jQuery's .hide() behavior.\n * @param element - Element to hide\n */\nexport function hideElement(element: HTMLElement): void {\n if (element.style.display !== 'none') {\n // Store current display value\n displayDataMap.set(\n element,\n element.style.display || getComputedStyle(element).display,\n );\n element.style.display = 'none';\n }\n}\n\n/**\n * Splits a selector list on its top-level commas, so `:not(a, b)` and\n * `[title=\"a,b\"]` stay whole.\n * @param selector - selector list\n * @return the selectors, trimmed, without empty ones\n */\nfunction splitSelectorList(selector: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let quote = '';\n let start = 0;\n\n for (let i = 0; i < selector.length; i++) {\n const c = selector[i]!;\n if (quote) {\n if (c === '\\\\') i++;\n else if (c === quote) quote = '';\n } else if (c === '\\\\') {\n i++;\n } else if (c === '\"' || c === \"'\") {\n quote = c;\n } else if (c === '(' || c === '[') {\n depth++;\n } else if (c === ')' || c === ']') {\n depth--;\n } else if (c === ',' && depth === 0) {\n parts.push(selector.slice(start, i));\n start = i + 1;\n }\n }\n parts.push(selector.slice(start));\n\n return parts.map((part) => part.trim()).filter(Boolean);\n}\n\n/**\n * Builds the test for the `ignore` setting: a selector list, or an array of\n * them, where jQuery's `:hidden` means \"not visible\", also inside a compound\n * selector such as `:hidden:not(.select2-hidden-accessible)`.\n * An empty string or array ignores nothing. A selector the browser rejects\n * ignores nothing (with a warning), so it can't turn validation off.\n * @param ignore - the `ignore` setting\n * @return function returning true for elements to ignore\n */\nexport function ignoreMatcher(\n ignore: string | string[] | null | undefined | false,\n): (element: HTMLElement) => boolean {\n const selectors = (Array.isArray(ignore) ? ignore : [ignore || ''])\n .flatMap((s) => splitSelectorList(String(s)))\n .map((selector) => {\n // :hidden alone, or as part of a compound selector: the rest of the\n // selector must match too (\"form :hidden\" → \"form *\")\n const hidden = /:hidden(?![\\w-])/.test(selector);\n const rest = selector\n .replace(/(^|[\\s>+~])?:hidden(?![\\w-])/g, (_m, before) =>\n before === undefined ? '' : `${before}*`,\n )\n .trim();\n return { hidden, rest: rest === '*' ? '' : rest };\n });\n\n if (!selectors.length) {\n return () => false;\n }\n\n const warned = new Set<string>();\n return (element) =>\n selectors.some(({ hidden, rest }) => {\n if (hidden && isVisible(element)) {\n return false;\n }\n if (!rest) {\n return true;\n }\n try {\n return element.matches(rest);\n } catch {\n if (!warned.has(rest)) {\n warned.add(rest);\n console.warn(`dv: ignore selector \"${rest}\" is not valid, skipped`);\n }\n return false;\n }\n });\n}\n\n/**\n * Whether a conditional parameter holds for the element, as jQuery's\n * `depend`: a boolean, a selector (true if it matches in the element's\n * form, e.g. '#other:checked') or a function of the element.\n * @param param - the parameter\n * @param element - the element being validated\n * @return true if the rule applies\n */\nexport function depend(param: unknown, element: FormControlElement): boolean {\n if (typeof param === 'boolean') {\n return param;\n }\n if (typeof param === 'function') {\n return !!param.call(element, element);\n }\n if (typeof param === 'string') {\n try {\n return !!element.form?.querySelector(param);\n } catch {\n // not a selector\n return true;\n }\n }\n return true;\n}\n","export class ObjectStore<T> {\n private readonly _store: Record<string, T> = {};\n private readonly _defaults: Record<string, T>;\n\n constructor(data: Record<string, T>) {\n this._store = data;\n this._defaults = { ...data };\n }\n\n /**\n * Whether the entry is still the built-in one (not changed with\n * `set`, `replace` or `dv.localize`).\n */\n isDefault(key: string): boolean {\n return key in this._defaults && this._store[key] === this._defaults[key];\n }\n\n keys(): string[] {\n return Object.keys(this._store);\n }\n\n get(key: string): T | undefined {\n return this._store[key];\n }\n\n set(key: string, value: T): void {\n this._store[key] = value;\n }\n\n replace(data: Record<string, T>): void {\n Object.entries(data).forEach(([key, value]) => {\n if (key in this._store) {\n this._store[key] = value;\n }\n });\n }\n}\n","import {\n AsyncValidationResult,\n RemoteParam,\n ValidationMethod,\n ValidationMethodInput,\n} from './types';\nimport { ObjectStore } from './objectStore';\nimport { depend } from './helpers';\n\n/**\n * Public API for accessing and managing validation methods.\n */\nexport const store = new ObjectStore<ValidationMethod>({\n required,\n minlength: minLength,\n maxlength: maxLength,\n rangelength: rangeLength,\n min,\n max,\n range,\n email,\n url,\n date,\n number,\n digits,\n equalto: equalTo,\n regex,\n nonalphamin: nonAlphaMin,\n creditcard: creditCard,\n extension,\n remote,\n});\n\n/**\n * Validates that the field has a value (is not blank). The parameter can\n * make it conditional: a boolean, a selector that must match in the form\n * (e.g. '#other:checked'), or a function of the element.\n * @return true if field is not blank, or the field isn't required now\n */\nfunction required({ blank, param, element }: ValidationMethodInput): boolean {\n return !blank || !depend(param, element);\n}\n\n/**\n * Validates that the field value has at least the minimum length.\n * @return true if blank or length meets minimum\n */\nfunction minLength({ blank, length, param }: ValidationMethodInput): boolean {\n return blank || length >= param;\n}\n\n/**\n * Validates that the field value does not exceed the maximum length.\n * @return true if blank or length within maximum\n */\nfunction maxLength({ blank, length, param }: ValidationMethodInput): boolean {\n return blank || length <= param;\n}\n\n/**\n * Validates that the field value length is within a specified range.\n * @return true if blank or length within range\n */\nfunction rangeLength({ blank, length, param }: ValidationMethodInput): boolean {\n return blank || (length >= param[0] && length <= param[1]);\n}\n\n/**\n * Validates that the field value is greater than or equal to a minimum value.\n * @return true if blank or value meets minimum\n */\nfunction min({ blank, value, param }: ValidationMethodInput): boolean {\n return blank || value >= param;\n}\n\n/**\n * Validates that the field value is less than or equal to a maximum value.\n * @return true if blank or value within maximum\n */\nfunction max({ blank, value, param }: ValidationMethodInput): boolean {\n return blank || value <= param;\n}\n\n/**\n * Validates that the field value is within a specified numeric range.\n * @return true if blank or value within range\n */\nfunction range({ blank, value, param }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n return value >= param[0] && value <= param[1];\n}\n\n/**\n * Validates that the field value is a valid email address format.\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid email format\n */\nfunction email({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const re =\n /^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;\n\n return re.test(value);\n}\n\n/**\n * Validates that the field value is a valid URL format.\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid URL format\n */\nfunction url({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const re =\n /^(?:(?:https?|ftp):)?\\/\\/(?:(?:[^\\]\\[?\\/<~#`!@$^&*()+=}|:\";',>{ ]|%[0-9A-Fa-f]{2})+(?::(?:[^\\]\\[?\\/<~#`!@$^&*()+=}|:\";',>{ ]|%[0-9A-Fa-f]{2})*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4])|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+[a-z\\u00a1-\\uffff]{2,}\\.?)(?::\\d{2,5})?(?:[\\/?#]\\S*)?$/i;\n\n return re.test(value);\n}\n\n/**\n * Validates that the field value is a valid ISO date format (YYYY-MM-DD or YYYY/MM/DD).\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid ISO date format\n */\nfunction date({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const re = /^\\d{4}[\\/\\-](0?[1-9]|1[012])[\\/\\-](0?[1-9]|[12][0-9]|3[01])$/;\n return re.test(value);\n}\n\n/**\n * Validates that the field value is a valid number (including decimals and comma-separated thousands).\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or valid number format\n */\nfunction number({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const re = /^(?:-?\\d+|-?\\d{1,3}(?:,\\d{3})+)?(?:-?\\.\\d+)?$/;\n return re.test(value);\n}\n\n/**\n * Validates that the field value contains only digits (no decimals or special characters).\n * @param blank - whether the field is blank\n * @param value - field value\n * @return true if blank or contains only digits\n */\nfunction digits({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n return /^\\d+$/.test(value);\n}\n\n/**\n * Validates that the field value equals the value of another field (e.g., password confirmation).\n * @return true if values match\n */\nfunction equalTo({ value, param }: ValidationMethodInput): boolean {\n const target =\n param instanceof Element ? param : document.querySelector(param);\n return !!target && value === (target as HTMLInputElement).value;\n}\n\n/**\n * Validates that the field value matches a regular expression.\n * @return true if blank or value matches pattern\n */\nfunction regex({ blank, value, param }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const match = new RegExp(param).exec(value);\n return !!match && match.index === 0 && match[0].length === value.length;\n}\n\n/**\n * Validates that the field value contains at least a minimum number of non-alphanumeric characters.\n * Used for password strength validation.\n * @return true if blank or value has enough non-alphanumeric characters\n */\nfunction nonAlphaMin({ blank, value, param }: ValidationMethodInput): boolean {\n if (blank || !param) {\n return true;\n }\n\n const match = value.match(/\\W/g);\n return !!match && match.length >= param;\n}\n\n/**\n * Validates that the field value matches a credit card number.\n * based on https://en.wikipedia.org/wiki/Luhn_algorithm\n * @return true if blank or value is a valid credit card number\n */\nfunction creditCard({ blank, value }: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n // only digits, spaces and dashes are allowed\n if (/[^0-9 \\-]+/.test(value)) {\n return false;\n }\n\n const strippedValue = value.replace(/\\D/g, '');\n\n let nCheck = 0;\n let bEven = false;\n\n // Basing min and max length on\n // https://dev.ean.com/general-info/valid-card-types/\n if (strippedValue.length < 13 || strippedValue.length > 19) {\n return false;\n }\n\n for (let n = strippedValue.length - 1; n >= 0; n--) {\n const cDigit = strippedValue.charAt(n);\n let nDigit = parseInt(cDigit, 10);\n if (bEven) {\n if ((nDigit *= 2) > 9) {\n nDigit -= 9;\n }\n }\n\n nCheck += nDigit;\n bEven = !bEven;\n }\n\n return nCheck % 10 === 0;\n}\n\n/**\n * Validates that the field value (a file name) ends with one of the allowed extensions.\n * Extensions are separated by commas or pipes, with or without a leading dot\n * (e.g. \"png,jpg\", \".png,.jpg\" or \"png|jpe?g\"). Defaults to common image types.\n * For file inputs, every selected file is checked.\n * @return true if blank or every file name has an allowed extension\n */\nfunction extension({\n blank,\n value,\n element,\n param,\n}: ValidationMethodInput): boolean {\n if (blank) {\n return true;\n }\n\n const allowed =\n typeof param === 'string' && param.trim() !== ''\n ? param\n .split(/[,|]/)\n .map((ext) => ext.trim().replace(/^\\./, ''))\n .filter(Boolean)\n .join('|')\n : 'png|jpe?g|gif';\n const re = new RegExp(`\\\\.(?:${allowed})$`, 'i');\n\n const files = element.files;\n if (files && files.length) {\n return Array.from(files).every((file) => re.test(file.name));\n }\n\n return re.test(value);\n}\n\n/**\n * Asks the server whether the value is valid (e.g. \"is this username free?\").\n * Sends the field as `name=value` (plus any `data`), GET by default, and\n * expects JSON: true when valid; false, or an error message, when invalid.\n * Results are cached by the validator until the value or data changes.\n * @return true if blank, otherwise a promise of the server's answer\n */\nfunction remote({\n blank,\n value,\n element,\n param,\n signal,\n}: ValidationMethodInput): boolean | Promise<AsyncValidationResult> {\n if (blank) {\n return true;\n }\n\n const options = (\n typeof param === 'string' ? { url: param } : param\n ) as Exclude<RemoteParam, string>;\n const method = (options.type || options.method || 'GET').toUpperCase();\n\n const fields = new URLSearchParams();\n fields.append(element.name, value);\n Object.entries(options.data ?? {}).forEach(([key, item]) => {\n const fieldValue = typeof item === 'function' ? item() : item;\n fields.set(key, fieldValue == null ? '' : String(fieldValue));\n });\n\n const url = new URL(options.url, document.baseURI);\n const headers: Record<string, string> = { Accept: 'application/json' };\n // like jQuery: marks the request as AJAX, but only on the same origin\n // (on another origin it would need a CORS preflight)\n if (url.origin === location.origin) {\n headers['X-Requested-With'] = 'XMLHttpRequest';\n }\n const init: RequestInit = {\n method,\n headers: { ...headers, ...options.headers },\n };\n if (signal) {\n init.signal = signal;\n }\n\n if (method === 'GET' || method === 'HEAD') {\n fields.forEach((fieldValue, key) => url.searchParams.set(key, fieldValue));\n } else {\n init.body = fields;\n }\n\n return fetch(url, init).then((response) => {\n if (!response.ok) {\n throw new Error(`remote: ${response.status} ${response.statusText}`);\n }\n return response.json();\n });\n}\n","import { store as methodStore } from './methods';\nimport { depend } from './helpers';\nimport { FormControlElement, ValidationRuleset } from './types';\n\n/**\n * Gets all validation rules for an element from multiple sources.\n * Merges rules from CSS classes, HTML attributes, data attributes, and programmatic settings.\n * @param element - form element to get rules for\n * @param settings - validator rule settings\n * @return {Object} - object containing all validation rules with the required rule first\n */\nexport function getRules(\n element: FormControlElement,\n settings: Record<string, ValidationRuleset>,\n): ValidationRuleset {\n // If nothing is selected, return empty object; can't chain anyway\n if (element == null || element.form == null) {\n return {};\n }\n\n let data = normalizeRules(\n {\n ...classRules(element),\n ...attributeRules(element),\n ...dataRules(element),\n ...staticRules(element, settings),\n },\n element,\n );\n\n // Make sure required is at front\n if ('required' in data) {\n const param = data.required;\n delete data.required;\n data = { required: param, ...data };\n }\n\n // and remote at the end: a pending request stops the other rules\n if ('remote' in data) {\n const param = data.remote;\n delete data.remote;\n data.remote = param;\n }\n\n return data;\n}\n\n/**\n * Default mapping of CSS class names to validation rules.\n * Allows class-based rule declaration like class=\"required email\".\n */\nconst classRuleSettings: Record<string, ValidationRuleset> = {\n required: { required: true },\n email: { email: true },\n url: { url: true },\n date: { date: true },\n number: { number: true },\n digits: { digits: true },\n creditcard: { creditcard: true },\n};\n\n/**\n * Adds or updates validation rules for a CSS class name.\n * @param className - class name to associate with rules\n */\nexport function addClassRule(className: string): void {\n classRuleSettings[className] = normalizeRule(className);\n}\n\n/**\n * Normalizes and processes validation rules for an element.\n * Removes false rules, applies conditional rules (`{ param, depends }`),\n * evaluates function parameters, and converts string/number values.\n * @param rules - raw validation rules object\n * @param element - the element the rules are for\n * @return normalized rules object\n */\nfunction normalizeRules(\n rules: ValidationRuleset,\n element: FormControlElement,\n): ValidationRuleset {\n Object.entries(rules).forEach(([key, value]) => {\n // Ignore rule when param is explicitly false, eg. required:false,\n // or missing, eg. an equalto whose other field isn't in the form\n if (value === false || value === null || value === undefined) {\n delete rules[key];\n return;\n }\n\n // { param, depends }: the rule applies only when depends holds\n if (\n typeof value === 'object' &&\n !(value instanceof Element) &&\n ('param' in value || 'depends' in value)\n ) {\n const keep = !('depends' in value) || depend(value.depends, element);\n if (keep) {\n rules[key] = value.param !== undefined ? value.param : true;\n } else {\n delete rules[key];\n }\n }\n });\n\n // a function parameter is called with the element, eg. required: () => …\n Object.keys(rules).forEach((key) => {\n if (typeof rules[key] === 'function') {\n rules[key] = rules[key].call(element, element);\n }\n });\n\n // Clean number parameters\n ['minlength', 'maxlength'].forEach((ruleKey) => {\n if (rules[ruleKey]) {\n rules[ruleKey] = Number(rules[ruleKey]);\n }\n });\n ['rangelength', 'range'].forEach((ruleKey) => {\n if (rules[ruleKey]) {\n if (Array.isArray(rules[ruleKey])) {\n rules[ruleKey] = [rules[ruleKey][0], rules[ruleKey][1]].map(Number) as [\n number,\n number,\n ];\n } else {\n const parts = rules[ruleKey]\n .toString()\n .replace(/[\\[\\]]/g, '')\n .split(/[\\s,]+/);\n rules[ruleKey] = [parts[0], parts[1]].map(Number) as [number, number];\n }\n }\n });\n\n return rules;\n}\n\n/**\n * Extracts validation rules from an element's CSS classes.\n * @param element - element to extract rules from\n * @return validation rules derived from CSS classes\n */\nfunction classRules(element: FormControlElement): ValidationRuleset {\n let rules = {};\n const classes = element.getAttribute('class');\n\n if (classes) {\n classes\n .trim()\n .split(/\\s/)\n .map((className) => className.toLowerCase())\n .forEach((className: string) => {\n if (className in classRuleSettings) {\n rules = { ...rules, ...classRuleSettings[className] };\n }\n });\n }\n\n return rules;\n}\n\n/**\n * Extracts validation rules from HTML attributes (required, minlength, etc.).\n * @param element - element to extract rules from\n * @return validation rules derived from HTML attributes\n */\nfunction attributeRules(element: FormControlElement): ValidationRuleset {\n const rules: ValidationRuleset = {};\n const type = element.type;\n\n for (const method of methodStore.keys()) {\n let value: string | null | boolean = element.getAttribute(method);\n\n // Support for <input required> in both html5 and older browsers\n if (method === 'required') {\n // Some browsers return an empty string for the required attribute\n // and non-HTML5 browsers might have required=\"\" markup\n if (value === '') {\n value = true;\n }\n\n // Force non-HTML5 browsers to return bool\n value = !!value;\n }\n\n normalizeAttributeRule(rules, type, method, value);\n }\n\n // 'maxlength' may be returned as -1, 2147483647 ( IE ) and 524288 ( safari ) for text inputs\n if (\n rules.maxlength &&\n /-1|2147483647|524288/.test(rules.maxlength.toString())\n ) {\n delete rules.maxlength;\n }\n\n return rules;\n}\n\n/**\n * Extracts validation rules from data attributes (data-rule-required, etc.).\n * @param element - element to extract rules from\n * @return validation rules derived from data attributes\n */\nfunction dataRules(element: FormControlElement): ValidationRuleset {\n const rules = {};\n const type = element.type;\n\n for (const method of methodStore.keys()) {\n const datasetKey =\n 'rule' +\n method.charAt(0).toUpperCase() +\n method.substring(1).toLowerCase();\n let value: string | null | boolean = element.dataset[datasetKey] ?? null;\n\n // Cast empty attributes like `data-rule-required` to `true`\n if (value === '' || value === 'true') {\n value = true;\n } else if (value === 'false') {\n value = false;\n }\n\n normalizeAttributeRule(rules, type, method, value);\n }\n\n return rules;\n}\n\n/**\n * Gets validation rules defined programmatically in validator settings.\n * @param element - element to get rules for\n * @param settings - Validator rule settings\n * @return validation rules from validator settings\n */\nexport function staticRules(\n element: FormControlElement,\n settings: Record<string, ValidationRuleset>,\n): ValidationRuleset {\n if (!settings || !settings[element.name]) {\n return {};\n }\n\n return normalizeRule(settings[element.name]!) || {};\n}\n\n/**\n * Normalizes a single attribute rule and adds it to the rules object.\n * Handles type coercion and special cases for different input types.\n * @param rules - rules object to add the rule to\n * @param type - input type attribute value\n * @param method - validation method name\n * @param value - attribute value\n */\nfunction normalizeAttributeRule(\n rules: ValidationRuleset,\n type: string,\n method: string,\n value: string | number | boolean | null,\n): void {\n // Convert the value to a number for number inputs, and for text for backwards compatability\n // allows type=\"date\" and others to be compared as strings\n if (\n /min|max|step/.test(method) &&\n (type === null || /number|range|text/.test(type)) &&\n value !== null\n ) {\n value = Number(value);\n }\n\n if (value || value === 0) {\n rules[method] = value;\n } else if (type === method && type !== 'range') {\n // Exception: the jquery validate 'range' method\n // does not test for the html5 'range' type\n rules[method] = true;\n }\n}\n\n/**\n * Converts string-based rule declarations to rule objects.\n * Transforms \"required email\" to {required: true, email: true}.\n * @param data - rule string or object\n * @return normalized rule object\n */\nexport function normalizeRule(\n data: ValidationRuleset | string,\n): ValidationRuleset {\n if (typeof data !== 'string') {\n return Object.fromEntries(\n Object.entries(data).map(([key, value]) => [key.toLowerCase(), value]),\n );\n }\n\n const transformed: ValidationRuleset = {};\n data\n .trim()\n .split(/\\s/)\n .map((token) => token.toLowerCase())\n .forEach((token) => {\n transformed[token] = true;\n });\n\n return transformed;\n}\n","import { format } from './helpers';\nimport { Validator } from './validator';\nimport { FormControlElement, ValidationMessage } from './types';\nimport { ObjectStore } from './objectStore';\n\n/**\n * Public API for accessing and managing error messages.\n */\nexport const store = new ObjectStore<string>({\n required: 'This field is required.',\n email: 'Please enter a valid email address.',\n url: 'Please enter a valid URL.',\n date: 'Please enter a valid date.',\n number: 'Please enter a valid number.',\n digits: 'Please enter only digits.',\n equalto: 'Please enter the same value again.',\n maxlength: 'Please enter no more than {0} characters.',\n minlength: 'Please enter at least {0} characters.',\n rangelength: 'Please enter a value between {0} and {1} characters long.',\n range: 'Please enter a value between {0} and {1}.',\n max: 'Please enter a value less than or equal to {0}.',\n min: 'Please enter a value greater than or equal to {0}.',\n\n regex: 'Please enter a value that matches the pattern {0}.',\n nonalphamin: 'Please enter at least {0} non-alphabetic characters.',\n creditcard: 'Please enter a valid credit card number.',\n extension: 'Please enter a value with a valid extension.',\n remote: 'Please fix this field.',\n});\n\n/**\n * Gets the appropriate error message for a validation rule failure.\n * Checks custom messages, data attributes, element title, and default messages in order.\n * @param element - form element that failed validation\n * @param rule - validation rule (string method name or object with method and parameters)\n * @param ignoreTitle - whether to ignore element title\n * @param customMessage - validator settings that may contain custom messages\n * @return formatted error message\n */\nexport function getMessage(\n this: Validator,\n element: FormControlElement,\n rule: { method: string; parameters?: any },\n ignoreTitle: boolean,\n customMessage?: ValidationMessage,\n): string {\n const message = [\n customMessage,\n customDataMessage(element, rule.method),\n (!ignoreTitle && element.title) || undefined,\n store.get(rule.method) as ValidationMessage | undefined,\n `<strong>Warning: No message defined for ${element.name}</strong>`,\n ].find((x) => x !== undefined)!;\n\n // a function message is called with the parameters and the element\n if (typeof message === 'function') {\n return String(message.call(this, rule.parameters, element));\n }\n\n const regex = /\\$?\\{(\\d+)}/g;\n\n if (/\\$?\\{(\\d+)}/g.test(message)) {\n return format(message.replace(regex, '{$1}'), rule.parameters) as string;\n } else {\n return message;\n }\n}\n\n/**\n * Gets a custom error message from element's data attributes.\n * Checks data-msg-{method} first, then falls back to data-msg.\n * @param element - form element\n * @param method - validation method name\n * @return custom message from data attribute if present\n */\nfunction customDataMessage(\n element: FormControlElement,\n method: string,\n): string | undefined {\n const dataSetKey =\n 'msg' + method.charAt(0).toUpperCase() + method.substring(1).toLowerCase();\n\n if (!element?.dataset) {\n return;\n }\n\n return element.dataset[dataSetKey] || element.dataset['msg'];\n}\n","import { Validator } from './validator';\n\nexport const validatorStore = new WeakMap<HTMLFormElement, Validator>();\n","import {\n FormControlElement,\n ValidationError,\n ValidatorSettings,\n} from './types';\n\n/**\n * CSS selectors for different types of form elements that should receive validation events\n */\nconst EVENT_TARGETS = {\n FOCUS_TARGETS: [\n \"[type='text']\",\n // an <input> without a type is a text input\n 'input:not([type])',\n \"[type='password']\",\n \"[type='file']\",\n 'select',\n 'textarea',\n \"[type='number']\",\n \"[type='search']\",\n \"[type='tel']\",\n \"[type='url']\",\n \"[type='email']\",\n \"[type='datetime']\",\n \"[type='date']\",\n \"[type='month']\",\n \"[type='week']\",\n \"[type='time']\",\n \"[type='datetime-local']\",\n \"[type='range']\",\n \"[type='color']\",\n \"[type='radio']\",\n \"[type='checkbox']\",\n 'button',\n \"input[type='button']\",\n ],\n CLICK_TARGETS: ['select', \"[type='radio']\", \"[type='checkbox']\"],\n} as const;\n\n/**\n * Event handler function type for validation events\n */\ntype ValidationEventHandler =\n boolean | ((element: FormControlElement, event: Event) => void);\n\n/**\n * Manages event delegation for form validation.\n * Handles attaching and removing event listeners with proper delegation logic.\n */\nexport class FormEventManager {\n private boundEventHandlers: {\n onFocusIn: ((e: Event) => void) | null;\n onFocusOut: ((e: Event) => void) | null;\n onKeyUp: ((e: Event) => void) | null;\n onClick: ((e: Event) => void) | null;\n onSubmit: ((e: Event) => void) | null;\n onInvalidForm: ((e: Event) => void) | null;\n } = {\n onFocusIn: null,\n onFocusOut: null,\n onKeyUp: null,\n onClick: null,\n onSubmit: null,\n onInvalidForm: null,\n };\n\n private submitButton: HTMLInputElement | HTMLButtonElement | null = null;\n\n constructor(\n private form: HTMLFormElement,\n private settings: ValidatorSettings,\n private validateCallback: () => boolean,\n private focusInvalidCallback: () => void,\n private shouldIgnoreElement: (element: HTMLElement) => boolean,\n /** holds the submit while async validations run; true if held */\n private holdSubmitCallback: (\n submitter: HTMLElement | null,\n ) => boolean = () => false,\n ) {}\n\n /**\n * Attaches all validation event listeners to the form\n */\n attachEventHandlers(): void {\n this.boundEventHandlers.onFocusIn = this.createDelegate(\n EVENT_TARGETS.FOCUS_TARGETS,\n this.settings.onfocusin,\n );\n this.boundEventHandlers.onFocusOut = this.createDelegate(\n EVENT_TARGETS.FOCUS_TARGETS,\n this.settings.onfocusout,\n );\n this.boundEventHandlers.onKeyUp = this.createDelegate(\n EVENT_TARGETS.FOCUS_TARGETS,\n this.settings.onkeyup,\n );\n this.boundEventHandlers.onClick = this.createDelegate(\n EVENT_TARGETS.CLICK_TARGETS,\n this.settings.onclick,\n );\n\n this.form.addEventListener('focusin', this.boundEventHandlers.onFocusIn);\n this.form.addEventListener('focusout', this.boundEventHandlers.onFocusOut);\n this.form.addEventListener('keyup', this.boundEventHandlers.onKeyUp);\n this.form.addEventListener('click', this.boundEventHandlers.onClick);\n\n if (this.settings.onsubmit) {\n this.boundEventHandlers.onSubmit = (e) =>\n this.handleSubmitForm(e as SubmitEvent);\n\n this.form.addEventListener('submit', this.boundEventHandlers.onSubmit);\n }\n\n // the validator wraps it to pass itself as the second argument\n const invalidHandler = this.settings.invalidHandler as\n ((event: CustomEvent) => void) | null;\n if (invalidHandler) {\n this.boundEventHandlers.onInvalidForm = (e) => {\n if (this.isCustomEvent(e)) {\n invalidHandler(e);\n }\n };\n this.form.addEventListener(\n 'invalid-form',\n this.boundEventHandlers.onInvalidForm,\n );\n }\n }\n\n triggerInvalidForm(errorList: ValidationError[]) {\n const event = new CustomEvent('invalid-form', {\n detail: errorList,\n cancelable: true,\n });\n this.form.dispatchEvent(event);\n }\n\n private isCustomEvent(event: Event): event is CustomEvent {\n return 'detail' in event;\n }\n\n private handleSubmitForm(e: SubmitEvent) {\n if (this.settings.debug) {\n e.preventDefault();\n }\n\n // the button used to submit, so its name/value can be sent along\n const submitter = e.submitter;\n this.submitButton =\n submitter instanceof HTMLButtonElement ||\n submitter instanceof HTMLInputElement\n ? submitter\n : null;\n\n // a button with formnovalidate or class=\"cancel\" (Cancel, Back, Save\n // draft) submits without validation, but still runs the submitHandler\n const skipValidation =\n !!this.submitButton &&\n (this.submitButton.hasAttribute('formnovalidate') ||\n this.submitButton.classList.contains('cancel'));\n\n if (!skipValidation) {\n const isValid = this.validateCallback();\n if (!isValid) {\n this.focusInvalidCallback();\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n\n // async validations (e.g. remote) are running: wait for them, then\n // the validator submits again if everything is valid\n if (this.holdSubmitCallback(submitter ?? null)) {\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n }\n\n let hidden: HTMLInputElement | null = null;\n\n // Insert a hidden input as a replacement for the missing submit button\n // if a submitHandler is passed as option\n if (this.submitButton?.name && this.settings.submitHandler) {\n hidden = document.createElement('input');\n hidden.setAttribute('type', 'hidden');\n hidden.setAttribute('name', this.submitButton.name);\n hidden.setAttribute('value', this.submitButton.value);\n this.form.appendChild(hidden);\n }\n\n if (this.settings.submitHandler && !this.settings.debug) {\n const result = this.settings.submitHandler(this.form, e);\n if (hidden) {\n // And clean up afterwards\n hidden.remove();\n }\n\n if (!result) {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n }\n\n /**\n * Removes all validation event listeners from the form\n */\n detachEventHandlers(): void {\n if (this.boundEventHandlers.onFocusIn) {\n this.form.removeEventListener(\n 'focusin',\n this.boundEventHandlers.onFocusIn,\n );\n }\n if (this.boundEventHandlers.onFocusOut) {\n this.form.removeEventListener(\n 'focusout',\n this.boundEventHandlers.onFocusOut,\n );\n }\n if (this.boundEventHandlers.onKeyUp) {\n this.form.removeEventListener('keyup', this.boundEventHandlers.onKeyUp);\n }\n if (this.boundEventHandlers.onClick) {\n this.form.removeEventListener('click', this.boundEventHandlers.onClick);\n }\n if (this.boundEventHandlers.onSubmit) {\n this.form.removeEventListener('submit', this.boundEventHandlers.onSubmit);\n }\n if (this.boundEventHandlers.onInvalidForm) {\n this.form.removeEventListener(\n 'invalid-form',\n this.boundEventHandlers.onInvalidForm,\n );\n }\n\n // Clear references\n this.boundEventHandlers.onFocusIn = null;\n this.boundEventHandlers.onFocusOut = null;\n this.boundEventHandlers.onKeyUp = null;\n this.boundEventHandlers.onClick = null;\n this.boundEventHandlers.onSubmit = null;\n this.boundEventHandlers.onInvalidForm = null;\n }\n\n /**\n * Creates a delegated event handler for the specified targets and handler\n */\n private createDelegate(\n targets: readonly string[],\n handler: ValidationEventHandler,\n ): (event: Event) => void {\n return (event: Event) => {\n let element = event.target as HTMLElement;\n if (element.tagName === 'OPTION') {\n element = element.closest('select') as HTMLElement;\n }\n\n // Skip if handler is disabled (boolean false)\n if (typeof handler === 'boolean') {\n return;\n }\n // Skip if element is null\n if (element === null) {\n return;\n }\n\n // Check if element matches any of the target selectors\n if (!element.matches(targets.join(', '))) {\n return;\n }\n\n // Ensure element belongs to the correct form\n if (!this.isElementInForm(element)) {\n return;\n }\n\n // Check if element should be ignored based on validator settings\n if (this.shouldIgnoreElement(element)) {\n return;\n }\n\n // Call the handler with the element and event\n handler(element as FormControlElement, event);\n };\n }\n\n /**\n * Checks if an element belongs to the validator's form\n */\n private isElementInForm(element: HTMLElement): boolean {\n const elementForm = (element as FormControlElement).form;\n return this.form === elementForm;\n }\n}\n","import { FormControlElement, ValidatorSettings } from './types';\nimport {\n elementValue,\n findByName,\n isBlankElement,\n isCheckableElement,\n} from './helpers';\nimport { Validator } from './validator';\n\nexport const ValidatorDefaults: ValidatorSettings = {\n ignore: ':hidden',\n errorClass: 'error',\n validClass: 'valid',\n pendingClass: 'pending',\n errorElement: 'label',\n wrapper: null,\n errorLabelContainer: null,\n errorContainer: null,\n onfocusin: onFocusIn,\n onfocusout: onFocusOut,\n onkeyup: onKeyUp,\n onclick: onClick,\n highlight: highlight,\n unhighlight: unhighlight,\n errorPlacement: null,\n focusCleanup: false,\n rules: {},\n messages: {},\n escapeHtml: false,\n showErrors: null,\n ignoreTitle: false,\n success: null,\n onsubmit: true,\n debug: false,\n invalidHandler: null,\n submitHandler: null,\n};\n\nfunction onFocusIn(this: Validator, element: FormControlElement): void {\n this.lastActive = element;\n\n if (this.settings.focusCleanup) {\n if (this.settings.unhighlight) {\n this.settings.unhighlight(element, this.errorClasses, this.validClasses);\n }\n this.hideErrors(element);\n }\n}\n\nfunction onFocusOut(this: Validator, element: FormControlElement): void {\n if (isCheckableElement(element)) {\n return;\n }\n if (\n !(element.name in this.submitted) &&\n isBlankElement(element, this.currentForm)\n ) {\n return;\n }\n\n this.element(element);\n}\n\nfunction onKeyUp(\n this: Validator,\n element: FormControlElement,\n event: Event,\n): void {\n const keyboardEvent = event as KeyboardEvent;\n if (\n keyboardEvent.which === 9 &&\n elementValue(element, this.currentForm) === ''\n ) {\n return;\n }\n\n // Avoid revalidate the field when pressing one of the following keys\n // Shift => 16\n // Ctrl => 17\n // Alt => 18\n // Caps lock => 20\n // End => 35\n // Home => 36\n // Left arrow => 37\n // Up arrow => 38\n // Right arrow => 39\n // Down arrow => 40\n // Insert => 45\n // Num lock => 144\n // AltGr key => 225\n const excludedKeys = [16, 17, 18, 20, 35, 36, 37, 38, 39, 40, 45, 144, 225];\n if (excludedKeys.includes(keyboardEvent.keyCode)) {\n return;\n }\n\n if (!(element.name in this.submitted) && !(element.name in this.invalid)) {\n return;\n }\n\n this.element(element);\n}\n\nfunction onClick(this: Validator, element: FormControlElement): void {\n // Click on selects, radiobuttons and checkboxes\n if (element.name in this.submitted) {\n this.element(element);\n }\n // Or option elements, check parent select in that case\n else if (element.parentNode && element.parentElement) {\n const name = element.parentElement.getAttribute('name');\n\n if (name && name in this.submitted) {\n this.element(element.parentNode as FormControlElement);\n }\n }\n}\n\nfunction highlight(\n this: Validator,\n element: FormControlElement,\n errorClasses: string[],\n validClasses: string[],\n): void {\n let targets = [element];\n if (element.type === 'radio') {\n targets = findByName(this.currentForm, element.name);\n }\n\n targets.forEach((el) => {\n el.classList.add(...errorClasses);\n el.classList.remove(...validClasses);\n });\n}\n\nfunction unhighlight(\n this: Validator,\n element: FormControlElement,\n errorClasses: string[],\n validClasses: string[],\n): void {\n let targets = [element];\n if (element.type === 'radio') {\n targets = findByName(this.currentForm, element.name);\n }\n\n targets.forEach((el) => {\n el.classList.remove(...errorClasses);\n el.classList.add(...validClasses);\n });\n}\n","import {\n depend,\n elementValue,\n escapeCssMeta,\n findByName,\n getValueLength,\n hideElement,\n idOrName,\n ignoreMatcher,\n isBlankElement,\n isCheckableElement,\n isVisible,\n objectLength,\n showElement,\n} from './helpers';\nimport { getRules, normalizeRule } from './rules';\nimport { getMessage } from './messages';\nimport { validatorStore } from './validatorStore';\nimport { store as methodStore } from './methods';\nimport { FormEventManager } from './eventManager';\nimport {\n FormControlElement,\n ValidationError,\n ValidationMessage,\n ValidationRuleset,\n ValidatorSettings,\n} from './types';\n\n/** A cached result of an async method, for one field and method. */\ninterface AsyncResult {\n /** value and parameters the result is for */\n key: string;\n /** true if valid, otherwise the error message (or null for the default) */\n result: true | string | null;\n /** the request failed: retried on the next validation the user starts */\n failed: boolean;\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return !!value && typeof (value as PromiseLike<unknown>).then === 'function';\n}\n\n/** Identifies the input of an async method: its values and parameters. */\nfunction asyncKey(values: string[], param: unknown): string {\n try {\n return JSON.stringify([values, param], (_key, value) =>\n typeof value === 'function' ? value() : value,\n );\n } catch {\n return JSON.stringify(values);\n }\n}\nimport { ValidatorDefaults } from './defaults';\n\n/**\n * Methods that, like jQuery's, pass a blank field as \"optional\" (jQuery's\n * \"dependency-mismatch\"). When one is a blank field's only rule, the field is\n * neutral: neither an error nor a success.\n */\nconst OPTIONAL_METHODS = new Set([\n 'minlength',\n 'maxlength',\n 'rangelength',\n 'min',\n 'max',\n 'range',\n 'email',\n 'url',\n 'date',\n 'unobtrusivedate',\n 'number',\n 'digits',\n 'creditcard',\n 'extension',\n 'remote',\n]);\n\nexport class Validator {\n currentForm: HTMLFormElement;\n errorContext!: HTMLElement;\n submitted: Record<string, string> = {};\n /** fields validated so far: their message, or false when valid */\n invalid: Record<string, string | false> = {};\n successList: FormControlElement[] = [];\n errorList: ValidationError[] = [];\n errorMap: Record<string, string> = {};\n toShow: HTMLElement[] = [];\n toHide: HTMLElement[] = [];\n currentElements: FormControlElement[] = [];\n labelContainer: HTMLElement | null = null;\n containers: HTMLElement[] = [];\n lastActive: FormControlElement | null = null;\n\n /** normalized rules */\n rules: Record<string, ValidationRuleset> = {};\n\n /** event delegation manager */\n private eventManager!: FormEventManager;\n\n /** whether init() added the novalidate attribute (so destroy() removes it) */\n private addedNoValidate = false;\n\n /** number of async validations (e.g. remote) still running */\n pendingRequest = 0;\n\n /** running async validations by field name */\n private pending: Record<\n string,\n { controller: AbortController; method: string; key: string }\n > = {};\n\n /** cached async results by field name, then method */\n private asyncResults: Record<string, Record<string, AsyncResult>> = {};\n\n /** a submit is waiting for the running async validations */\n private formSubmitted = false;\n\n /** the button that started the held submit */\n private heldSubmitter: HTMLElement | null = null;\n\n /** while > 0, cached failed requests are reused instead of retried */\n private reuseFailed = 0;\n\n /** the ignore setting, and the test built from it */\n private ignoreTest?: [\n ValidatorSettings['ignore'],\n (el: HTMLElement) => boolean,\n ];\n\n /** fields whose equalto rule has run: rechecked when the other field blurs */\n private equalToChecked = new Set<string>();\n\n /** callbacks waiting for pendingRequest to reach 0 */\n private settleWaiters: (() => void)[] = [];\n\n settings: ValidatorSettings = ValidatorDefaults;\n\n /**\n * Initializes a new validator instance for the given form with optional configuration settings.\n * @param form - form element to validate\n * @param options - optional user configuration settings\n */\n constructor(form: HTMLFormElement, options?: Partial<ValidatorSettings>) {\n this.currentForm = form;\n this.settings = { ...this.settings, ...options };\n\n this.normalizeSettings();\n this.init();\n }\n\n /**\n * Normalizes Validator settings.\n * Currently, this only binds function settings to validator instance.\n */\n normalizeSettings(): void {\n // bind function settings to this validator instance\n [\n 'onfocusin',\n 'onfocusout',\n 'onkeyup',\n 'onclick',\n 'highlight',\n 'unhighlight',\n 'errorPlacement',\n 'submitHandler',\n ].forEach((key) => {\n const setting = this.settings[key as keyof ValidatorSettings];\n if (setting && typeof setting === 'function') {\n (this.settings as any)[key] = setting.bind(this);\n }\n });\n\n // like jQuery: invalidHandler(event, validator)\n const invalidHandler = this.settings.invalidHandler;\n if (invalidHandler) {\n this.settings.invalidHandler = (event) =>\n invalidHandler.call(this, event, this);\n }\n\n // give each validator its own messages map, so setRules() never writes\n // into the shared defaults or the caller's options object\n this.settings.messages = { ...this.settings.messages };\n\n // transform method names to lowercase in messages\n if (this.settings.messages) {\n Object.keys(this.settings.messages).forEach((elementName) => {\n const messages = this.settings.messages[elementName];\n\n // Only transform if it's an object (not a string)\n if (typeof messages === 'object' && messages !== null) {\n const normalizedMessages: Record<string, ValidationMessage> = {};\n\n Object.keys(messages).forEach((methodName) => {\n normalizedMessages[methodName.toLowerCase()] =\n messages[methodName]!;\n });\n\n this.settings.messages[elementName] = normalizedMessages;\n }\n });\n }\n }\n\n /**\n * Sets up DOM references and attaches event handlers to the form.\n */\n init(): void {\n // turn off the browser's own validation (popups, blocked submits),\n // which would otherwise run before ours for required, type=\"email\", etc.\n if (!this.currentForm.hasAttribute('novalidate')) {\n this.currentForm.setAttribute('novalidate', 'novalidate');\n this.addedNoValidate = true;\n }\n\n if (this.settings.errorLabelContainer) {\n this.labelContainer = document.querySelector(\n this.settings.errorLabelContainer,\n );\n }\n this.errorContext = this.labelContainer || this.currentForm;\n\n // every element errorContainer matches is shown and hidden; error labels\n // only go in the first element errorLabelContainer matches\n const containers = [this.labelContainer];\n if (this.settings.errorContainer) {\n containers.push(\n ...document.querySelectorAll<HTMLElement>(this.settings.errorContainer),\n );\n }\n this.containers = containers.filter(Boolean) as HTMLElement[];\n\n this.rules = {};\n Object.entries(this.settings.rules).forEach(([key, value]) => {\n this.rules[key] = normalizeRule(value);\n });\n\n // like jQuery's equalTo: leaving the other field rechecks this one\n const onfocusout = this.settings.onfocusout;\n if (onfocusout) {\n this.settings.onfocusout = (element, event) => {\n onfocusout(element, event);\n this.recheckEqualTo(element);\n };\n }\n\n this.eventManager = new FormEventManager(\n this.currentForm,\n this.settings,\n () => this.form(),\n () => this.focusInvalid(),\n (element) => this.shouldIgnore(element),\n (submitter) => this.holdSubmit(submitter),\n );\n this.eventManager.attachEventHandlers();\n }\n\n /**\n * Sets the rules (and optionally the messages) for a field by name after\n * the validator has been created, replacing any rules set for it before.\n * Useful when fields are added to the form dynamically.\n * Rules from HTML attributes, data attributes and classes still apply.\n * @param name - name attribute of the field\n * @param rules - rules for the field, or null to remove them\n * @param messages - custom messages for the field, keyed by method name\n * @example\n * validator.setRules('email', { required: true, email: true }, {\n * required: 'We need your email.',\n * });\n */\n setRules(\n name: string,\n rules: ValidationRuleset | string | null,\n messages?: Record<string, ValidationMessage> | string,\n ): void {\n if (rules === null) {\n delete this.rules[name];\n delete this.settings.messages[name];\n return;\n }\n\n this.rules[name] = normalizeRule(rules);\n\n if (typeof messages === 'string') {\n this.settings.messages[name] = messages;\n } else if (messages) {\n this.settings.messages[name] = Object.fromEntries(\n Object.entries(messages).map(([method, msg]) => [\n method.toLowerCase(),\n msg,\n ]),\n );\n }\n }\n\n /**\n * Resets the validator state.\n */\n reset(): void {\n this.successList = [];\n this.errorList = [];\n this.errorMap = {};\n this.toShow = [];\n this.toHide = [];\n this.currentElements = [];\n }\n\n /**\n * Validates all form elements.\n * @return true if the form is valid, false otherwise\n */\n form(): boolean {\n this.retryFailedRequests();\n this.prepareForm();\n this.currentElements = this.elements();\n for (const element of this.currentElements) {\n this.check(element);\n }\n\n this.submitted = { ...this.submitted, ...this.errorMap };\n this.invalid = { ...this.errorMap };\n if (!this.valid()) {\n this.eventManager.triggerInvalidForm(this.errorList);\n }\n this.showErrors();\n this.notifySettled();\n return this.valid();\n }\n\n /**\n * Validates a single element within the form.\n * @param element - element to validate\n * @return true if the element is valid, false otherwise\n */\n element(element: FormControlElement): boolean {\n this.retryFailedRequests();\n const target = this.validationTargetFor(element);\n if (target === undefined) {\n delete this.invalid[element.name];\n return true;\n }\n\n this.prepareElement(target);\n this.currentElements = [target];\n\n const result = this.check(target);\n // keep valid fields as false (not deleted): onkeyup revalidates every\n // field that has been validated once, as jQuery does\n this.invalid[target.name] = result ? false : 'Invalid';\n\n if (!this.numberOfInvalids()) {\n this.toHide.push(...this.containers);\n }\n this.showErrors();\n\n // add aria-invalid status for screen readers\n element.setAttribute('aria-invalid', (!result).toString());\n\n this.notifySettled();\n return result;\n }\n\n prepareElement(element: FormControlElement): void {\n this.reset();\n this.toHide = this.errorsFor(element);\n }\n\n /**\n * Returns true if there are currently no validation errors.\n * @return {boolean} - true if there are no validation errors, false otherwise\n */\n valid(): boolean {\n return this.size() === 0;\n }\n\n /**\n * Returns the number of validation errors.\n * @return number of validation errors\n */\n size(): number {\n return this.errorList.length;\n }\n\n /**\n * Returns a list of all form elements that need to be validated.\n * @return list of form elements\n */\n elements(): FormControlElement[] {\n const rulesCache: Record<string, boolean> = {};\n\n const selector = 'input, select, textarea';\n // :disabled also matches fields inside <fieldset disabled>\n const notSelector =\n 'input[type=\"submit\"], [type=\"reset\"], [type=\"image\"], :disabled';\n\n const elements = (\n Array.from(this.currentForm.querySelectorAll(selector)) as HTMLElement[]\n ).filter(\n (el) => !el.matches(notSelector) && !this.shouldIgnore(el),\n ) as FormControlElement[];\n\n // getAttribute: a field named \"id\" shadows form.id\n const formId = this.currentForm.getAttribute('id');\n if (formId) {\n const escapedId = escapeCssMeta(formId);\n\n const outsideElements = (\n Array.from(document.querySelectorAll(selector)) as HTMLElement[]\n ).filter(\n (el) =>\n el.matches(`[form=\"${escapedId}\"]`) &&\n !el.matches(notSelector) &&\n !this.shouldIgnore(el),\n ) as FormControlElement[];\n\n elements.push(...outsideElements);\n }\n\n return elements.filter((el) => {\n const form = el.form;\n if (form !== this.currentForm) {\n return false;\n }\n\n const name = el.name || el.getAttribute('name');\n if (\n !name ||\n name in rulesCache ||\n !objectLength(getRules(el, this.rules))\n ) {\n return false;\n }\n\n rulesCache[name] = true;\n return true;\n });\n }\n\n /**\n * Returns an array of currently valid elements from the last validation.\n * @return list of valid form elements\n */\n validElements(): FormControlElement[] {\n const invalid = this.invalidElements();\n // fields with a running async validation are not known to be valid yet\n return this.currentElements.filter(\n (el) => !invalid.includes(el) && !(el.name in this.pending),\n );\n }\n\n /**\n * Returns an array of currently invalid elements from the last validation.\n * @return list of invalid form elements\n */\n invalidElements(): FormControlElement[] {\n return this.errorList.map((e) => e.element);\n }\n\n /**\n * Runs all validation rules against an element and returns true if valid.\n * @param element - element to validate\n * @return true if the element is valid, false otherwise\n */\n check(element: FormControlElement): boolean {\n element = this.validationTargetFor(element);\n\n const rules = getRules(element, this.rules);\n const elValue = elementValue(element, this.currentForm);\n\n const value = (Array.isArray(elValue) ? elValue[0] : elValue) ?? '';\n const values = Array.isArray(elValue) ? elValue : [elValue];\n\n const length = getValueLength(element, this.currentForm);\n const blank = isBlankElement(element, this.currentForm);\n\n // a running async validation for a previous value is out of date\n const running = this.pending[element.name];\n if (\n running &&\n (!(running.method in rules) ||\n running.key !== asyncKey(values, rules[running.method]))\n ) {\n this.abortRequest(element);\n }\n\n // a lone rule that doesn't apply (blank optional field, or required\n // whose condition is false) leaves the field neutral: no success\n const ruleCount = Object.keys(rules).length;\n let neutral = false;\n\n for (const method in rules) {\n const rule = { method, parameters: rules[method] };\n\n const methodFunc = methodStore.get(method);\n if (!methodFunc) {\n console.warn(`Validation method \"${method}\" not found. Skipping.`);\n continue;\n }\n\n // async methods: reuse the result while the value is unchanged\n const cached = this.asyncResults[element.name]?.[method];\n if (cached && cached.key === asyncKey(values, rule.parameters)) {\n if (cached.result === true) {\n continue;\n }\n // like jQuery, remote's own message is formatted with the value\n // (\"'{0}' is already taken\"), not with the request options\n this.formatAndAdd(\n element,\n rule,\n cached.result ??\n (method === 'remote'\n ? this.getMessage(element, { method, parameters: value })\n : undefined),\n );\n return false;\n }\n\n if (method === 'equalto') {\n this.equalToChecked.add(element.name);\n }\n\n if (this.pending[element.name]?.method !== method) {\n const controller = new AbortController();\n const result = methodFunc({\n blank,\n value: value,\n values,\n length,\n element,\n param: rule.parameters,\n signal: controller.signal,\n });\n\n if (!isPromiseLike(result)) {\n if (!result) {\n this.formatAndAdd(element, rule);\n return false;\n }\n neutral =\n ruleCount === 1 &&\n (method === 'required'\n ? !depend(rule.parameters, element)\n : blank && OPTIONAL_METHODS.has(method));\n continue;\n }\n\n const key = asyncKey(values, rule.parameters);\n this.startRequest(element, { controller, method, key });\n result.then(\n (response) => this.finishRequest(element, key, controller, response),\n () => this.finishRequest(element, key, controller, null),\n );\n }\n\n // Pending: not an error (yet). Keep the current message visible and\n // stop here; the field is validated again when the answer arrives.\n const shown = this.errorsFor(element);\n this.toHide = this.toHide.filter((el) => !shown.includes(el));\n return true;\n }\n\n if (!neutral && objectLength(rules)) {\n this.successList.push(element);\n }\n return true;\n }\n\n /**\n * Validates again the fields whose equalto rule points at the element\n * (and has run before), e.g. ConfirmPassword when Password changes.\n */\n private recheckEqualTo(element: FormControlElement): void {\n this.equalToChecked.forEach((name) => {\n const field = findByName(this.currentForm, name)[0];\n if (!field || field === element) {\n return;\n }\n const param = getRules(field, this.rules)['equalto'];\n let target: Element | null = null;\n try {\n target =\n param instanceof Element ? param : document.querySelector(param);\n } catch {\n // not a selector: the equalto rule itself reports it\n }\n if (target === element) {\n this.element(field);\n }\n });\n }\n\n /**\n * Returns a promise that resolves once no async validations are running.\n */\n settled(): Promise<void> {\n if (this.pendingRequest === 0) {\n return Promise.resolve();\n }\n return new Promise((resolve) => this.settleWaiters.push(resolve));\n }\n\n /**\n * Runs fn reusing the results of failed requests instead of retrying them.\n * @internal\n */\n withCachedResults<T>(fn: () => T): T {\n this.reuseFailed++;\n try {\n return fn();\n } finally {\n this.reuseFailed--;\n }\n }\n\n private retryFailedRequests(): void {\n if (this.reuseFailed) {\n return;\n }\n Object.values(this.asyncResults).forEach((byMethod) => {\n Object.keys(byMethod).forEach((method) => {\n if (byMethod[method]!.failed) {\n delete byMethod[method];\n }\n });\n });\n }\n\n private startRequest(\n element: FormControlElement,\n request: { controller: AbortController; method: string; key: string },\n ): void {\n this.abortRequest(element);\n this.pending[element.name] = request;\n this.pendingRequest++;\n if (this.settings.pendingClass) {\n element.classList.add(this.settings.pendingClass);\n }\n }\n\n private abortRequest(element: FormControlElement): void {\n const running = this.pending[element.name];\n if (!running) {\n return;\n }\n\n running.controller.abort();\n this.endRequest(element);\n\n // the user changed the field while a submit was waiting: drop the submit\n if (this.pendingRequest === 0) {\n this.formSubmitted = false;\n this.heldSubmitter = null;\n }\n }\n\n private endRequest(element: FormControlElement): void {\n delete this.pending[element.name];\n this.pendingRequest = Math.max(0, this.pendingRequest - 1);\n if (this.settings.pendingClass) {\n element.classList.remove(this.settings.pendingClass);\n }\n }\n\n private finishRequest(\n element: FormControlElement,\n key: string,\n controller: AbortController,\n response: unknown,\n ): void {\n // a newer validation, a reset or destroy() replaced this one\n const running = this.pending[element.name];\n if (controller.signal.aborted || running?.controller !== controller) {\n return;\n }\n this.endRequest(element);\n\n const valid = response === true || response === 'true';\n (this.asyncResults[element.name] ??= {})[running.method] = {\n key,\n result: valid\n ? true\n : typeof response === 'string' && response !== ''\n ? response\n : null,\n failed: response === null,\n };\n\n // validate the field again: the answer is cached now, and any rules\n // after the async one run too (unless the field or validator is gone)\n if (validatorStore.get(this.currentForm) === this && element.isConnected) {\n this.withCachedResults(() => this.element(element));\n }\n\n if (this.pendingRequest === 0) {\n this.resumeSubmit();\n this.notifySettled();\n }\n }\n\n /** Called on submit while async validations are running. */\n private holdSubmit(submitter: HTMLElement | null): boolean {\n if (this.pendingRequest === 0) {\n return false;\n }\n this.formSubmitted = true;\n this.heldSubmitter = submitter;\n return true;\n }\n\n /** Submits the held submit once everything is valid, as the user meant to. */\n private resumeSubmit(): void {\n if (!this.formSubmitted) {\n return;\n }\n this.formSubmitted = false;\n const submitter = this.heldSubmitter;\n this.heldSubmitter = null;\n\n this.withCachedResults(() => {\n if (!this.form()) {\n this.focusInvalid();\n return;\n }\n if (this.holdSubmit(submitter)) {\n return;\n }\n\n const form = this.currentForm;\n const isSubmitter =\n submitter instanceof HTMLElement &&\n (submitter as HTMLButtonElement).form === form &&\n submitter.matches(\n 'button[type=\"submit\"], button:not([type]), input[type=\"submit\"], input[type=\"image\"]',\n );\n form.requestSubmit(isSubmitter ? submitter : undefined);\n });\n }\n\n private notifySettled(): void {\n if (this.pendingRequest !== 0) {\n return;\n }\n const waiters = this.settleWaiters;\n this.settleWaiters = [];\n waiters.forEach((resolve) => resolve());\n }\n\n /**\n * Returns all error label elements currently in the DOM.\n * @return array of error label elements\n */\n errors(): HTMLElement[] {\n const errorClass = this.errorClasses.join('.');\n return Array.from(\n this.errorContext.querySelectorAll(\n `${this.settings.errorElement}.${errorClass}`,\n ),\n );\n }\n\n showErrors(errors?: Record<string, string>) {\n if (errors) {\n // Add items to error list and map\n this.errorMap = { ...this.errorMap, ...errors };\n this.errorList = Object.entries(this.errorMap).map(([name, message]) => ({\n message,\n method: message,\n element: findByName(this.currentForm, name)[0]!,\n }));\n\n // Remove items from success list\n this.successList = this.successList.filter((e) => !(e.name in errors));\n }\n\n if (this.settings.showErrors) {\n return this.settings.showErrors.call(this, this.errorMap, this.errorList);\n }\n\n return this.defaultShowErrors();\n }\n\n defaultShowErrors(): void {\n for (const error of this.errorList) {\n if (this.settings.highlight) {\n this.settings.highlight(\n error.element,\n this.errorClasses,\n this.validClasses,\n );\n }\n this.showLabel(error.element, error.message);\n }\n\n if (this.errorList.length) {\n this.toShow = this.toShow.concat(this.containers);\n }\n\n if (this.settings.success) {\n for (const element of this.successList) {\n this.showLabel(element);\n }\n }\n\n if (this.settings.unhighlight) {\n for (const element of this.validElements()) {\n this.settings.unhighlight(\n element,\n this.errorClasses,\n this.validClasses,\n );\n }\n }\n\n this.toHide = this.toHide.filter((el) => !this.toShow.includes(el));\n this.hideErrors();\n this.addWrapper(...this.toShow).forEach(showElement);\n }\n\n formatAndAdd(\n element: FormControlElement,\n rule: { method: string; parameters: any },\n message: string = this.getMessage(element, rule),\n ): void {\n this.errorList.push({ message, element, method: rule.method });\n this.errorMap[element.name] = message;\n this.submitted[element.name] = message;\n }\n\n prepareForm(): void {\n this.reset();\n this.toHide = this.errors().concat(this.containers);\n }\n\n hideErrors(element?: FormControlElement): void {\n // we're either hiding all errors, or just the errors for a specific element\n let targets = this.toHide;\n if (element) {\n targets = this.errorsFor(element);\n }\n\n for (const el of targets) {\n if (!this.containers.includes(el)) {\n el.innerText = '';\n }\n\n this.addWrapper(el).forEach(hideElement);\n }\n }\n\n addWrapper(...elements: HTMLElement[]): HTMLElement[] {\n const result = Array.isArray(elements) ? elements : [elements];\n\n if (!this.settings.wrapper) {\n return result;\n }\n\n const wrappers = result\n .map((el) => el.parentElement)\n .filter((el) => el && el.matches(this.settings.wrapper!));\n\n result.push(...(wrappers as HTMLElement[]));\n\n return result;\n }\n\n showLabel(element: FormControlElement, message?: string): void {\n let errors = this.errorsFor(element);\n const elementID = idOrName(element);\n const describedBy = element.getAttribute('aria-describedby');\n\n if (errors.length) {\n // Non-label error exists but is not currently associated with element via aria-describedby\n const labelSelector = `label[for='${escapeCssMeta(elementID)}']`;\n const nonLabelExists = errors\n .map((e) => e.closest(labelSelector))\n .every((e) => e === null);\n\n const noDescriberAssociation = () => {\n if (describedBy === null) {\n return true;\n }\n const firstErrorId = errors[0]?.getAttribute('id') ?? null;\n if (firstErrorId === null) {\n return true;\n }\n\n const split = describedBy.split(' ');\n return split.indexOf(firstErrorId) === -1;\n };\n\n if (nonLabelExists && noDescriberAssociation()) {\n const firstErrorId = errors[0]!.getAttribute('id')!;\n this.addErrorAriaDescribedBy(element, firstErrorId);\n }\n\n // Refresh error/success class\n errors.forEach((el) => {\n el.classList.remove(this.settings.validClass);\n el.classList.add(...this.errorClasses);\n if (this.settings.escapeHtml) {\n el.innerText = message || '';\n } else {\n el.innerHTML = message || '';\n }\n });\n } else {\n const newError = document.createElement(this.settings.errorElement);\n newError.setAttribute('id', `${elementID}-error`);\n newError.classList.add(...this.errorClasses);\n if (this.settings.escapeHtml) {\n newError.innerText = message || '';\n } else {\n newError.innerHTML = message || '';\n }\n\n // Maintain reference to the element(s) to be placed into the DOM\n let insert = newError;\n if (this.settings.wrapper) {\n const wrapper = document.createElement(this.settings.wrapper);\n wrapper.appendChild(newError);\n insert = wrapper;\n }\n\n if (this.labelContainer) {\n this.labelContainer.appendChild(insert);\n } else if (element.dataset.errorPlacement) {\n const target = document.querySelector(element.dataset.errorPlacement);\n if (target) {\n target.appendChild(insert);\n } else {\n console.warn(\n `dv: data-error-placement target \"${element.dataset.errorPlacement}\" not found, using default placement`,\n );\n element.after(insert);\n }\n } else if (this.settings.errorPlacement) {\n this.settings.errorPlacement(insert, element);\n } else {\n element.after(insert);\n }\n\n // Link error back to the element\n if (newError.matches('label')) {\n // If the error is a label, then associate using 'for'\n newError.setAttribute('for', elementID);\n }\n // If the element is not a child of an associated label, then it's necessary\n // to explicitly apply aria-describedby\n else if (\n !newError.parentElement?.matches(\n `label[for='${escapeCssMeta(elementID)}']`,\n )\n ) {\n this.addErrorAriaDescribedBy(element, newError.getAttribute('id')!);\n }\n\n errors = [newError];\n }\n\n if (!message && this.settings.success) {\n errors.forEach((e) => (e.innerText = ''));\n\n const successSetting = this.settings.success;\n if (typeof successSetting === 'string') {\n errors.forEach((e) => e.classList.add(successSetting));\n } else {\n successSetting(errors, element);\n }\n }\n\n this.toShow.push(...errors);\n }\n\n addErrorAriaDescribedBy(element: FormControlElement, errorId: string) {\n let describedBy = element.getAttribute('aria-describedby');\n\n if (!describedBy) {\n describedBy = errorId;\n } else if (\n !describedBy.match(new RegExp(`\\\\b${escapeCssMeta(errorId)}\\\\b`))\n ) {\n describedBy += ` ${errorId}`;\n }\n\n element.setAttribute('aria-describedby', describedBy);\n }\n\n errorsFor(element: FormControlElement): HTMLElement[] {\n const name = escapeCssMeta(idOrName(element));\n const describer = element.getAttribute('aria-describedby');\n\n let selector = `label[for='${name}'], label[for='${name}'] *`;\n if (describer) {\n const escapedDescriber = escapeCssMeta(describer).replace(/\\s+/g, ', #');\n selector += `, #${escapedDescriber}`;\n }\n\n return this.errors().filter((el) => el.matches(selector));\n }\n\n numberOfInvalids(): number {\n return objectLength(this.invalid);\n }\n\n destroy(): void {\n this.resetForm();\n validatorStore.delete(this.currentForm);\n this.eventManager.detachEventHandlers();\n if (this.addedNoValidate) {\n this.currentForm.removeAttribute('novalidate');\n }\n }\n\n resetForm(): void {\n // stop running async validations and forget their results\n Object.entries(this.pending).forEach(([name, { controller }]) => {\n controller.abort();\n if (this.settings.pendingClass) {\n findByName(this.currentForm, name).forEach((el) =>\n el.classList.remove(this.settings.pendingClass),\n );\n }\n });\n this.pending = {};\n this.pendingRequest = 0;\n this.asyncResults = {};\n this.formSubmitted = false;\n this.heldSubmitter = null;\n this.notifySettled();\n\n this.invalid = {};\n this.submitted = {};\n this.equalToChecked.clear();\n this.prepareForm();\n this.hideErrors();\n\n this.elements().forEach((el) => el.removeAttribute('aria-invalid'));\n this.resetElements();\n }\n\n resetElements(): void {\n if (this.settings.unhighlight) {\n for (const element of this.elements()) {\n this.settings.unhighlight(element, this.errorClasses, []);\n findByName(this.currentForm, element.name).forEach((el) =>\n el.classList.remove(...this.validClasses),\n );\n }\n } else {\n this.elements().forEach((el) => {\n el.classList.remove(...this.errorClasses);\n el.classList.remove(...this.validClasses);\n });\n }\n }\n\n validationTargetFor(element: FormControlElement): FormControlElement {\n let targets = [element];\n if (isCheckableElement(element)) {\n targets = findByName(this.currentForm, element.name);\n }\n\n return targets.filter((t) => !this.shouldIgnore(t))[0]!;\n }\n\n /**\n * Returns true if the element should be skipped from receiving validation.\n * @param element - element to check\n * @return true if the element should be skipped, false otherwise\n */\n shouldIgnore(element: HTMLElement): boolean {\n // built again only when the setting changes\n if (!this.ignoreTest || this.ignoreTest[0] !== this.settings.ignore) {\n this.ignoreTest = [\n this.settings.ignore,\n ignoreMatcher(this.settings.ignore),\n ];\n }\n return this.ignoreTest[1](element);\n }\n\n getMessage(\n element: FormControlElement,\n rule: string | { method: string; parameters?: any },\n ) {\n if (typeof rule === 'string') {\n rule = { method: rule };\n }\n\n let customMessage: ValidationMessage | undefined;\n const msgSettings = this.settings.messages[element.name];\n if (msgSettings && typeof msgSettings === 'string') {\n customMessage = msgSettings;\n } else if (msgSettings && typeof msgSettings === 'object') {\n customMessage = msgSettings[rule.method];\n }\n\n return getMessage.call(\n this,\n element,\n rule,\n this.settings.ignoreTitle,\n customMessage,\n );\n }\n\n focusInvalid(): void {\n const lastActive = this.findLastActive();\n const firstErrorElement = this.errorList.length\n ? this.errorList[0]!.element\n : null;\n\n const el = lastActive || firstErrorElement;\n if (!el || !isVisible(el)) {\n return;\n }\n\n // Focus the element\n el.focus();\n\n // Manually dispatch \"focusin\"\n const focusInEvent = new Event('focusin', { bubbles: true });\n el.dispatchEvent(focusInEvent);\n }\n\n findLastActive() {\n const lastActive = this.lastActive;\n if (!lastActive) return;\n\n const matches = this.errorList.filter(\n (n) => n.element.name === lastActive.name,\n );\n\n return matches.length === 1 ? lastActive : undefined;\n }\n\n get errorClasses(): string[] {\n return this.settings.errorClass.split(' ').filter(Boolean);\n }\n\n get validClasses(): string[] {\n return this.settings.validClass.split(' ').filter(Boolean);\n }\n}\n","/**\n * @fileoverview Core validation library for client-side form validation.\n * Provides programmatic API for validating forms and form elements.\n */\n\nimport { Validator } from './validator';\nimport { validatorStore } from './validatorStore';\nimport { addClassRule, getRules } from './rules';\nimport { store as methods } from './methods';\nimport { store as messages } from './messages';\nimport {\n FormControlElement,\n ValidationError,\n ValidationMethod,\n ValidationRuleset,\n ValidatorSettings,\n} from './types';\n\n/**\n * Creates or retrieves a validator for a form or form element.\n * If a validator already exists for the element, returns the existing validator.\n *\n * @param selector - CSS selector string or HTMLElement to validate\n * @param [options] - Validation options including rules, messages, and callbacks\n * @returns Validator instance or undefined if element not found\n * @example\n * // Validate a form with rules\n * dv.validate('#myForm', {\n * rules: {\n * email: { required: true, email: true },\n * password: { required: true, minlength: 8 }\n * }\n * });\n */\nexport function validate(\n selector: string | Element | null,\n options?: Partial<ValidatorSettings>,\n): Validator | undefined {\n if (!selector) {\n console.warn(\"No element selected, can't validate.\");\n return;\n }\n\n const element =\n selector instanceof Element ? selector : document.querySelector(selector);\n\n if (!element) {\n console.warn(\"No element selected, can't validate.\");\n return;\n }\n if (!(element instanceof HTMLFormElement)) {\n const elementType = element.tagName || 'unknown element';\n console.warn(\n `Element must be a form element for validation. Received: ${elementType}`,\n );\n return;\n }\n\n if (validatorStore.has(element)) {\n return validatorStore.get(element);\n }\n\n const validator = new Validator(element, options);\n validatorStore.set(element, validator);\n return validator;\n}\n\n/**\n * Validates form or form elements and returns whether they are valid.\n * Triggers validation and returns the result without submitting the form.\n *\n * @param selector - Element(s) to validate:\n * CSS selector, element, or array of elements\n * @returns True if all elements are valid, false otherwise\n * @example\n * // Check if form is valid\n * if (dv.valid('#myForm')) {\n * console.log('Form is valid!');\n * }\n *\n * // Check specific fields\n * if (dv.valid(['#email', '#password'])) {\n * console.log('Email and password are valid!');\n * }\n */\nexport function valid(selector: string | HTMLElement | HTMLElement[]): boolean {\n let elements: any[] = [];\n if (typeof selector === 'string') {\n elements = Array.from(document.querySelectorAll(selector));\n } else if (selector instanceof HTMLElement) {\n elements = [selector];\n } else if (Array.isArray(selector)) {\n elements = selector;\n }\n\n if (elements[0].matches('form')) {\n return validate(elements[0])?.form() ?? false;\n }\n\n const errorList: ValidationError[] = [];\n let valid = true;\n const validator = validate(elements[0].form);\n if (!validator) {\n return false;\n }\n\n elements.forEach((el) => {\n valid = validator.element(el) && valid;\n if (!valid) {\n errorList.push(...validator.errorList);\n }\n });\n\n validator.errorList = errorList;\n return valid;\n}\n\n/**\n * Like `dv.valid`, but waits for async validations (such as `remote`) to\n * finish, and resolves with the final result.\n *\n * @param selector - Element(s) to validate:\n * CSS selector, element, or array of elements\n * @returns Promise of true if all elements are valid, false otherwise\n * @example\n * if (await dv.validAsync('#signupForm')) {\n * await saveDraft();\n * }\n */\nexport async function validAsync(\n selector: string | HTMLElement | HTMLElement[],\n): Promise<boolean> {\n let result = valid(selector);\n\n const first =\n typeof selector === 'string'\n ? document.querySelector(selector)\n : Array.isArray(selector)\n ? selector[0]\n : selector;\n const form =\n first instanceof HTMLFormElement\n ? first\n : ((first as FormControlElement | null)?.form ?? null);\n const validator = form ? validatorStore.get(form) : undefined;\n\n // wait for the answers, then validate again with them; repeat if a field\n // changed meanwhile and started a new request\n while (validator?.pendingRequest) {\n await validator.settled();\n result = validator.withCachedResults(() => valid(selector));\n }\n return result;\n}\n\n/**\n * Gets the validation rules for an element.\n *\n * @param selector - CSS selector string or HTMLElement\n * @returns Object containing validation rules for the element\n * @example\n * // Get rules for an input\n * const emailRules = dv.rules('#email');\n * console.log(emailRules); // { required: true, email: true }\n */\nexport function rules(selector: string | HTMLElement): ValidationRuleset {\n const element =\n selector instanceof HTMLElement\n ? selector\n : document.querySelector(selector);\n\n const validator = validate((element as any).form);\n if (!validator) {\n return {};\n }\n\n return getRules(element as FormControlElement, validator.rules);\n}\n\n/**\n * Adds a custom validation method, or replaces an existing one (as jQuery's\n * `$.validator.addMethod` does, e.g. `number` for a culture).\n * The method can be used in validation rules by its name.\n *\n * @param name - Name of the validation method\n * @param method - Validation function that returns true if valid\n * @param message - Default error message for this validation method; when\n * omitted, an existing method keeps its message\n * @param addAsClassRule - Whether to allow using this method as a CSS class (default: false). Set to true for methods that take no param.\n * @example\n * // Add a custom phone validation method\n * dv.addMethod('phone', function(blank, value, element) {\n * return blank || /^\\d{3}-\\d{3}-\\d{4}$/.test(value);\n * }, 'Please enter a valid phone number (xxx-xxx-xxxx)');\n *\n * // Use in validation rules\n * dv.validate('#myForm', {\n * rules: {\n * phoneNumber: { phone: true }\n * }\n * });\n */\nexport function addMethod(\n name: string,\n method: ValidationMethod,\n message?: string,\n addAsClassRule: boolean = false,\n) {\n name = name.trim().toLowerCase();\n if (name === '' || !/^[a-zA-Z0-9]+$/.test(name)) {\n console.warn(\n 'Invalid method name: must be non-empty and only alphanumeric characters.',\n );\n return;\n }\n methods.set(name, method);\n if (message !== undefined) {\n messages.set(name, message);\n }\n if (addAsClassRule) {\n addClassRule(name);\n }\n}\n\n/**\n * Replaces default error messages or validation methods with localized versions.\n *\n * @param data - Object containing either localized error messages (string values) or\n * validation methods (function values). If values are strings, replaces\n * error messages. If values are functions, replaces validation methods.\n *\n * @example\n * // Localize error messages to French\n * dv.localize({\n * required: 'Ce champ est obligatoire.',\n * email: 'Veuillez entrer une adresse email valide.',\n * minlength: 'Veuillez entrer au moins {0} caractères.'\n * });\n */\nexport function localize(\n data: Record<string, string> | Record<string, ValidationMethod>,\n) {\n const firstValue = Object.values(data)[0];\n\n if (typeof firstValue === 'string') {\n messages.replace(data as Record<string, string>);\n } else {\n methods.replace(data as Record<string, ValidationMethod>);\n }\n}\n\n/**\n * Map of validation error messages.\n */\nexport { messages };\n\n/**\n * Map of validation methods.\n */\nexport { methods };\n\n/**\n * Default export containing all validation functions and stores.\n * @namespace\n */\nexport default {\n validate,\n valid,\n validAsync,\n rules,\n addMethod,\n localize,\n messages,\n methods,\n};\n"],"names":["isVisible","el","offsetWidth","offsetHeight","getClientRects","length","objectLength","obj","count","key","undefined","findByName","form","name","selector","escapeCssMeta","elements","Array","from","querySelectorAll","formId","getAttribute","outsideElements","document","filter","matches","push","isCheckableElement","element","test","type","text","replace","elementValue","map","value","validity","badInput","substring","idx","lastIndexOf","fileInputValue","formatString","source","params","isArray","forEach","param","index","RegExp","String","idOrName","id","getValueLength","nodeName","toLowerCase","isBlankElement","selectedOptions","selected","o","displayDataMap","WeakMap","showElement","storedDisplay","get","style","display","delete","hideElement","set","getComputedStyle","ignoreMatcher","ignore","selectors","flatMap","s","parts","depth","quote","start","i","c","slice","part","trim","Boolean","splitSelectorList","hidden","rest","_m","before","warned","Set","some","has","add","depend","call","querySelector","ObjectStore","constructor","data","this","_store","_defaults","isDefault","keys","Object","entries","store","required","blank","minlength","maxlength","rangelength","min","max","range","email","url","date","number","digits","equalto","target","Element","regex","match","exec","nonalphamin","creditcard","strippedValue","nCheck","bEven","n","cDigit","charAt","nDigit","parseInt","extension","allowed","split","ext","join","re","files","every","file","remote","signal","options","method","toUpperCase","fields","URLSearchParams","append","item","fieldValue","URL","baseURI","headers","Accept","origin","location","init","searchParams","body","fetch","then","response","ok","Error","status","statusText","json","getRules","settings","rules","depends","ruleKey","Number","toString","normalizeRules","classRules","attributeRules","dataRules","staticRules","classRuleSettings","classes","className","methodStore","normalizeAttributeRule","datasetKey","dataset","normalizeRule","fromEntries","transformed","token","getMessage","rule","ignoreTitle","customMessage","message","customDataMessage","title","find","x","parameters","args","dataSetKey","validatorStore","EVENT_TARGETS","FormEventManager","validateCallback","focusInvalidCallback","shouldIgnoreElement","holdSubmitCallback","boundEventHandlers","onFocusIn","onFocusOut","onKeyUp","onClick","onSubmit","onInvalidForm","submitButton","attachEventHandlers","createDelegate","onfocusin","onfocusout","onkeyup","onclick","addEventListener","onsubmit","e","handleSubmitForm","invalidHandler","isCustomEvent","triggerInvalidForm","errorList","event","CustomEvent","detail","cancelable","dispatchEvent","debug","preventDefault","submitter","HTMLButtonElement","HTMLInputElement","hasAttribute","classList","contains","stopPropagation","submitHandler","createElement","setAttribute","appendChild","result","remove","detachEventHandlers","removeEventListener","targets","handler","tagName","closest","isElementInForm","elementForm","ValidatorDefaults","errorClass","validClass","pendingClass","errorElement","wrapper","errorLabelContainer","errorContainer","lastActive","focusCleanup","unhighlight","errorClasses","validClasses","hideErrors","submitted","currentForm","keyboardEvent","which","includes","keyCode","invalid","parentNode","parentElement","highlight","errorPlacement","messages","escapeHtml","showErrors","success","isPromiseLike","asyncKey","values","JSON","stringify","_key","OPTIONAL_METHODS","Validator","successList","errorMap","toShow","toHide","currentElements","labelContainer","containers","addedNoValidate","pendingRequest","pending","asyncResults","formSubmitted","heldSubmitter","reuseFailed","equalToChecked","settleWaiters","normalizeSettings","setting","bind","elementName","normalizedMessages","methodName","errorContext","recheckEqualTo","eventManager","focusInvalid","shouldIgnore","holdSubmit","setRules","msg","reset","retryFailedRequests","prepareForm","check","valid","notifySettled","validationTargetFor","prepareElement","numberOfInvalids","errorsFor","size","rulesCache","notSelector","escapedId","validElements","invalidElements","elValue","running","abortRequest","ruleCount","neutral","methodFunc","cached","formatAndAdd","controller","AbortController","startRequest","finishRequest","shown","field","settled","Promise","resolve","withCachedResults","fn","byMethod","failed","request","abort","endRequest","Math","aborted","_a","_b","isConnected","resumeSubmit","isSubmitter","HTMLElement","requestSubmit","waiters","errors","defaultShowErrors","error","showLabel","concat","addWrapper","innerText","wrappers","elementID","describedBy","labelSelector","firstErrorId","indexOf","noDescriberAssociation","addErrorAriaDescribedBy","innerHTML","newError","insert","after","successSetting","errorId","describer","escapedDescriber","destroy","resetForm","removeAttribute","clear","resetElements","t","ignoreTest","msgSettings","findLastActive","firstErrorElement","focus","focusInEvent","Event","bubbles","validate","HTMLFormElement","validator","async","validAsync","first","addMethod","addAsClassRule","methods","localize"],"mappings":";;;;;;;;;;yOAOM,SAAUA,EAAUC,GACxB,SAAUA,EAAGC,aAAeD,EAAGE,cAAgBF,EAAGG,iBAAiBC,OACrE,CAOM,SAAUC,EAAaC,GAC3B,IAAIC,EAAQ,EACZ,IAAK,MAAMC,KAAOF,OAECG,IAAbH,EAAIE,IAAmC,OAAbF,EAAIE,KAA8B,IAAbF,EAAIE,IACrDD,IAGJ,OAAOA,CACT,CAQM,SAAUG,EACdC,EACAC,GAEA,MAAMC,EAAW,UAAUC,EAAcF,OAEnCG,EAAWC,MAAMC,KAAKN,EAAKO,iBAAiBL,IAG5CM,EAASR,EAAKS,aAAa,MACjC,GAAID,EAAQ,CACV,MAAME,EAAkBL,MAAMC,KAC5BK,SAASJ,iBAAiBL,IAC1BU,OAAQvB,GAAOA,EAAGwB,QAAQ,UAAUV,EAAcK,SACpDJ,EAASU,QAAQJ,EACnB,CAEA,OAAON,CACT,CAOM,SAAUW,EAAmBC,GACjC,MAAO,kBAAkBC,KAAKD,EAAQE,MAAQ,GAChD,CAQM,SAAUf,EAAcgB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