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
|
||||
(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 []
|
||||
(-> js/document
|
||||
(.getElementById "issuer")))
|
||||
|
@ -45,6 +52,15 @@
|
|||
(when-not (st/blank? 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 []
|
||||
(-> js/document
|
||||
(.getElementById "auth")))
|
||||
|
@ -70,25 +86,6 @@
|
|||
(.-value)
|
||||
(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! []
|
||||
(-> (form)
|
||||
(.-classList)
|
||||
|
@ -117,7 +114,6 @@
|
|||
(validate-auth!)
|
||||
(set-validated!))
|
||||
|
||||
|
||||
(defn init []
|
||||
(-> js/document
|
||||
(.getElementById "generate-button")
|
||||
|
|
Loading…
Reference in a new issue