start refactoring for issuer
This commit is contained in:
parent
a694acb1fa
commit
e2bf9a25cd
1 changed files with 19 additions and 23 deletions
|
@ -35,6 +35,13 @@
|
||||||
(set-validation-result! name
|
(set-validation-result! name
|
||||||
(expound/expound-str spec content {:print-specs? false})))))
|
(expound/expound-str spec content {:print-specs? false})))))
|
||||||
|
|
||||||
|
(defn validate-optional! [name spec]
|
||||||
|
(let [content (get-content-from-element name)]
|
||||||
|
(if (or (st/blank? content) (s/valid? spec content))
|
||||||
|
(set-validation-result! name "")
|
||||||
|
(set-validation-result! name
|
||||||
|
(expound/expound-str spec content {:print-specs? false})))))
|
||||||
|
|
||||||
(defn issuer []
|
(defn issuer []
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "issuer")))
|
(.getElementById "issuer")))
|
||||||
|
@ -45,6 +52,15 @@
|
||||||
(when-not (st/blank? issuer-str)
|
(when-not (st/blank? issuer-str)
|
||||||
(keyword issuer-str))))
|
(keyword issuer-str))))
|
||||||
|
|
||||||
|
(defn validate-issuer! []
|
||||||
|
(let [name "issuer"
|
||||||
|
spec ::kc/issuer
|
||||||
|
issuer (issuer-from-document)]
|
||||||
|
(if (or (st/blank? issuer) (s/valid? spec issuer))
|
||||||
|
(set-validation-result! name "")
|
||||||
|
(set-validation-result! name
|
||||||
|
(expound/expound-str spec issuer {:print-specs? false})))))
|
||||||
|
|
||||||
(defn auth []
|
(defn auth []
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "auth")))
|
(.getElementById "auth")))
|
||||||
|
@ -59,9 +75,9 @@
|
||||||
(when-not (st/blank? (issuer-from-document))
|
(when-not (st/blank? (issuer-from-document))
|
||||||
{:issuer (issuer-from-document)})))
|
{:issuer (issuer-from-document)})))
|
||||||
|
|
||||||
(defn auth-from-document []
|
(defn auth-from-document []
|
||||||
(edn/read-string (-> (auth)
|
(edn/read-string (-> (auth)
|
||||||
(.-value))))
|
(.-value))))
|
||||||
|
|
||||||
(defn set-output!
|
(defn set-output!
|
||||||
[input]
|
[input]
|
||||||
|
@ -70,25 +86,6 @@
|
||||||
(.-value)
|
(.-value)
|
||||||
(set! input)))
|
(set! input)))
|
||||||
|
|
||||||
(defn set-issuer-validation-result!
|
|
||||||
[validation-result]
|
|
||||||
(-> js/document
|
|
||||||
(.getElementById "issuer-validation")
|
|
||||||
(.-innerHTML)
|
|
||||||
(set! validation-result))
|
|
||||||
(-> (issuer)
|
|
||||||
(.setCustomValidity validation-result))
|
|
||||||
validation-result)
|
|
||||||
|
|
||||||
(defn validate-issuer! []
|
|
||||||
(let [issuer (issuer-from-document)]
|
|
||||||
(print-debug (js->clj issuer))
|
|
||||||
(print-debug (st/blank? issuer))
|
|
||||||
(if (or (st/blank? issuer) (s/valid? ::kc/issuer issuer))
|
|
||||||
(set-issuer-validation-result! "")
|
|
||||||
(set-issuer-validation-result!
|
|
||||||
(expound/expound-str ::kc/issuer issuer {:print-specs? false})))))
|
|
||||||
|
|
||||||
(defn set-validated! []
|
(defn set-validated! []
|
||||||
(-> (form)
|
(-> (form)
|
||||||
(.-classList)
|
(.-classList)
|
||||||
|
@ -117,7 +114,6 @@
|
||||||
(validate-auth!)
|
(validate-auth!)
|
||||||
(set-validated!))
|
(set-validated!))
|
||||||
|
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "generate-button")
|
(.getElementById "generate-button")
|
||||||
|
|
Loading…
Reference in a new issue