mob2
This commit is contained in:
parent
86b6e890cf
commit
bb7757338c
1 changed files with 7 additions and 5 deletions
|
@ -18,10 +18,11 @@
|
|||
|
||||
(s/def ::deserializer fn?)
|
||||
(s/def ::optional boolean?)
|
||||
(def dom-function-parameter (s/keys :opt-un [::deserializer ::optional]))
|
||||
(defn-spec get-content-from-element any?
|
||||
[name string?
|
||||
& {:keys [deserializer optional]
|
||||
:or {deserializer nil optional false}} (s/keys :opt-un [::deserializer ::optional])]
|
||||
:or {deserializer nil optional false}} dom-function-parameter]
|
||||
(let [content (-> (get-element-by-id name)
|
||||
(.-value))]
|
||||
(cond
|
||||
|
@ -47,7 +48,7 @@
|
|||
[name string?
|
||||
spec any?
|
||||
& {:keys [deserializer optional]
|
||||
:or {deserializer nil optional false}} (s/keys :opt-un [::deserializer ::optional])]
|
||||
:or {deserializer nil optional false}} dom-function-parameter]
|
||||
(let [content (get-content-from-element name :optional optional :deserializer deserializer)]
|
||||
(if (or (and optional (st/blank? content))
|
||||
(s/valid? spec content))
|
||||
|
@ -55,14 +56,15 @@
|
|||
(set-validation-result! name
|
||||
(expound/expound-str spec content {:print-specs? false})))))
|
||||
|
||||
(defn set-output!
|
||||
[input]
|
||||
(defn-spec set-output! any?
|
||||
[input string?]
|
||||
(-> js/document
|
||||
(.getElementById "output")
|
||||
(.-value)
|
||||
(set! input)))
|
||||
|
||||
(defn set-validated! []
|
||||
(defn-spec set-validated! any?
|
||||
[]
|
||||
(-> (get-element-by-id "form")
|
||||
(.-classList)
|
||||
(.add "was-validated")))
|
||||
|
|
Loading…
Reference in a new issue