Fork me on GitHub
#malli
<
2020-09-05
>
ikitommi07:09:57

The demo on ClojureD was schematized malli fn's emitting clj-kondo type definitions. I'll make a real impl out of that now with the clj-together funding. Not the first thing, but will most likely need help with that @borkdude, will poke you when about to do that. The second thing, which would be a nice experiment is if malli itself could be used inside clj-kondo to validate both malli data and schemas, e.g.

(do-it {:Type "AWS::AppSync::ApiKey"
        :Descriptionz "kikka"})
.. would emit clj-kondo errors:
{:ApiId ["missing required key"]
 :Descriptionz ["should be spelled :Description"]}

ikitommi07:09:10

autocomplete-stuff: I don't know how to do those, and most likely don't have to study that, but happy to help on Malli side if someone want's to try that out

ikitommi08:09:09

with the :multi dispatch key validation, it would yield:

(do-it {:Type "AWS::ApiGatway::UsagePlan"
        :Description "kikka"
        :UsagePlanName "kukka"}
.. would emit clj-kondo errors:
{:Type ["should be spelled \"AWS::ApiGateway::UsagePlan\""]}

borkdude08:09:18

@ikitommi I tried a similar thing using the type system in clj-kondo. It can be done, but it only works at places where literal maps are passed. So when you use assoc et al, it already breaks (although I think I have some logic which tries to account for that, it's been a while)

borkdude08:09:57

as an experiment, it'd be interesting what comes out of it

👍 3
borkdude08:09:25

I recently listened to a podcast with Tony Kay. He is working on something similar called GuardRails Pro which will be closed source

borkdude08:09:09

It would be great to have a free alternative

ikitommi13:09:21

Looked up and listened the ClojureScript Podcast about GRP, sounds interesting.

ikitommi13:09:34

Interesting times ahead, sounds like Clojure is getting mature :)

ikitommi13:09:03

@jeroenvandijk small changes: • :dispatch is mandatory in :multi, e.g. can’t set via Schema creations opts => this makes it visible for error handling • malli.error/with-spell-checking now understands :multi dispatch values if the :dispatch value is a keyword

ikitommi13:09:29

(-> (m/explain
      Schema
      {:Type "AWS::AppSync::ApiKey"
       :Descriptionz "kikka"})
    (me/with-spell-checking)
    (me/humanize))
; loaded "AWS::AppSync::ApiKey"
; => {:ApiId ["missing required key"]
;     :Descriptionz ["should be spelled :Description"]}

(-> Schema
    (m/explain
      {:Type "AWS::ApiGatway::UsagePlan"
       :Description "kikka"
       :UsagePlanName "kukka"})
    (me/with-spell-checking)
    (me/humanize))
; => {:Type ["did you mean AWS::ApiGateway::UsagePlan"]}

jeroenvandijk13:09:48

Wow, super nice. Thanks!