Hello, I want to build a general data-building ui, that takes a description of the datastructure as input (a malli schema, this time around). I couldn’t find much prior work in this regard. I have a half-baked prototype here: https://escherize.com/w/data-desk/
So far, that mostly works for int?
string?
boolean?
:vector
and :map
and combinations of them.
So do you know of anything similar?
As for the implementation, I’m using a local atom and this multimethod: https://github.com/escherize/data-desk/blob/main/src/data_desk/views.cljs#L37
Ok. Thanls
I'd like to validate inside a function that the function is called with valid arguments.
Should I use :=>
? How exactly?
The readme doens't cover it
Here is what I am doing
(def =>plus [:=> [:cat int? int?] int?])
(defn plus [x y]
(when-not
(m/validate (second =>plus) [x y])
(throw (ex-info "invalid input" {})))
(+ x y))
Is there a more idiomatic way?
there will be malli.instrument
, while waiting, there is malli-indtrument
- https://github.com/setzer22/malli-instrument
Very cool! Any reason why it's not yet part of malli?
just time to merge & cleanup, the original issue is here: https://github.com/metosin/malli/issues/349
the function checker code shuould be reused between malli.generate and malli.instrument.
Is someone already working on this consolidation?
please ask on the issue. on my summer backlog if no-one has time. need this too after the vacations.
ok. will do
README should cover that
Is there something I can do to make the results of mu/union
more condensed?
(mu/union (mu/union nil? empty?) empty?)
=> [:or [:or nil? empty?] empty?]