A way better approach for form validation. Feels good now.

This commit is contained in:
2022-07-19 08:24:33 -07:00
parent b84600e4f1
commit cab3a84903
18 changed files with 530 additions and 111 deletions

View File

@@ -5,7 +5,7 @@
[react :as react]))
(def good-$ #"^\-?[0-9]+(\.[0-9][0-9])?$")
(defn -money-field [{:keys [min max disabled on-change value class style placeholder]}]
(defn -money-field [{:keys [min max disabled on-blur on-change value class style placeholder]}]
(let [[ parsed-amount set-parsed-amount] (react/useState {:parsed value
:raw (cond
(str/blank? value)
@@ -59,7 +59,9 @@
(set-parsed-amount {:raw ""
:parsed nil})
(on-change nil)))
(on-change nil))
(when on-blur
(on-blur)))
:min min
:max max
:step "0.01"