This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-21
Channels
- # bangalore-clj (11)
- # beginners (82)
- # boot (1)
- # braveandtrue (29)
- # cider (16)
- # cljdoc (2)
- # cljs-dev (2)
- # clojure (74)
- # clojure-dev (3)
- # clojure-italy (2)
- # clojure-mke (1)
- # clojure-nl (4)
- # clojure-sg (1)
- # clojure-spec (1)
- # clojure-uk (53)
- # clojure-ukraine (1)
- # clojurescript (33)
- # cursive (29)
- # datomic (59)
- # editors (4)
- # emacs (14)
- # fulcro (2)
- # graphql (12)
- # hoplon (2)
- # nyc (4)
- # onyx (5)
- # parinfer (10)
- # pedestal (22)
- # re-frame (11)
- # reagent (35)
- # ring-swagger (5)
- # shadow-cljs (150)
- # tools-deps (9)
- # vim (1)
- # yada (20)
I want to have value event.target.name
event.target.value
event.type
. Just thinking if instead make this fake “map” with static values for tests purpose
or I should simulate webbrowser without no excuse hmm… not sure what is right choice
you mean like calling (on-blur (clj->js {:type "foo" :target {:name "foo" :value "foo"}})
?
I mean fn which I want to test will look something like that:
(defn fn-name->value [form]
"assoc input value to atom {}
The best with on-change."
(let [{:keys [names->value names->msg names->validations specs->msg]} form]
(fn [event]
(let [name (keyword event.target.name)
value event.target.value
spec (get names->spec name)]
(validate->atom names->msg specs->msg spec name value)
(swap! names->value #(assoc % name value))))))
fn use event.target.name
or that way or another. I will rewrite it later probably to (-> …)
All after all my goal is to make library which could be use with leiningen and shadow-cljs to help work with form validation and spec
Hmm I guess only on on-blur
and change
events and event.target.name
event.target.value
event.type
. At least at that moment.
well the above doesn't require any DOM. you don't need actual event object you just need something with the correct properties
(defn test-fn [form event]
(println "event.type" event.type)
(when-not (re-matches #".*!.*" event.target.value)
{:msg "Password should have '!' character"
:level :warn}))
(def init (-> {:names->value {:email ""
:password ""}
:names->validations {:email [::spec-email]
:password [::spec-password test-fn]}
:specs->msg {::spec-email "Typo? It doesn't look valid."
::spec-password "Password is required."}}
(form/init-form)))
BTW what do you think about this TL; DR; module? It will let use specs, fns and different levels of :error :warn :info etc. Such opensource make sense? I didn’t find any which satisfy me. Does it look ok (I know that is too primitive description)?[mui/text-field
{:on-change value->form
:on-blur fn-name->show
:error (form/show-error? form :email)
:helper-text (if email-error?
(form/get-error form :email)
" ")
:name "email"}]
^inputsIs anyone using or has ever used hipo? https://github.com/jeluard/hipo
Well, (go (print (<! ...)))
works, but I'd like to capture the output somewhere for interrogation.
you could use an atom and just reset!
it in the go block which might feel a little cleaner
Snowflake uses Javascript for UDF’s. Has anyone that uses Snowflake thought about using Clojurescript for such UDFs? https://docs.snowflake.net/manuals/sql-reference/udf-overview.html