malli

https://github.com/metosin/malli :malli:
Hankstenberg 2020-11-26T11:02:26.143300Z

The more I look at it the more I want to use malli schemas as a single source of truth for everything. Are there any resources about generating ui models from malli schemas? I think the idea to integrate it with Domino was floating around once, but the current version doesn't mention malli. How else could it be done? My go-to framework for UI stuff is usually re-frame. Malli could be integrated so that re-frame's db is generated from it. And to validate state changes, of course. It could also be bound to visual representations of actual components I guess. Would be grateful for any reference to existing work in this area.

Hankstenberg 2020-11-30T06:53:51.160Z

Thanks a lot for the input! I'm still trying to wrap my head around everything. I think Datascript (re-posh)+datasync are the right tools to connect front-end state and back-end state, I think I will try to find a way to make this stack (malli-)schema-driven.

rutledgepaulv 2020-11-26T14:32:34.143700Z

I have played with this a bit. I eventually came to a realization that I should first transform malli into an intermediate representation prior to generating the UI state because there are additional things you'll want to know about each node, like whether the field is "dirty" and has been "visited", etc. So in other words.. first I would go through the work of figuring out a sensible IR and generating forms from that, and then work backwards and generate that initial IR from malli.

👍 1
rutledgepaulv 2020-11-26T14:35:13.143900Z

That said, my initial attempt of using malli directly (and still struggling with how to do the reagent cursors) is here: https://rutledgepaulv.github.io/ui-kit/#!/ui_kit.forms https://github.com/RutledgePaulV/ui-kit/blob/master/src/cljs/ui_kit/visitors.cljs

👍 1
ikitommi 2020-11-26T18:59:11.145300Z

👍 1
rutledgepaulv 2020-11-26T19:03:45.146100Z

Wonder if there's an opportunity to improve error messages here:

rutledgepaulv 2020-11-26T19:03:51.146500Z

(def stream
  (logs client
        {:operation "readCoreV1NamespacedPodLog"}
        {}))
Execution error (ExceptionInfo) at kube-api.utils/validation-error (utils.clj:87).
Invalid request.
{:path-params ["missing required key"]}

(def stream
  (logs client
        {:operation "readCoreV1NamespacedPodLog"}
        {:path-params {}}))
Execution error (ExceptionInfo) at kube-api.utils/validation-error (utils.clj:87).
Invalid request.
{:path-params
 {:name ["missing required key"], :namespace ["missing required key"]}}

rutledgepaulv 2020-11-26T19:04:36.147500Z

if there's a missing key, insert the key with an empty value and run validation on that empty value too so you can report not only the missing collection but also what needs to be in the collection?

rutledgepaulv 2020-11-26T19:04:52.147800Z

probably breaks down in some edge cases.. thinking

ikitommi 2020-11-26T19:06:23.148800Z

you could run default-value-transformer to add empty maps first.

👍 1
ikitommi 2020-11-26T19:08:28.149200Z

(m/decode
  [:map
   [:path-params [:map
                  [:name :string]
                  [:description :string]]]]
  nil
  (mt/default-value-transformer
    {:defaults {:map (constantly {})
                :string (constantly "")}}))
; => {:path-params {:name "", :description ""}}

rutledgepaulv 2020-11-26T19:14:38.149600Z

thanks! yes, that's working for me