I was wondering if lsp integration was in the cards π I would love to be able to write a malli schema and from it receive strong editor support for data that needs to conform to that schema (like some tools provide for xsd).
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"]}
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
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\""]}
@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)
as an experiment, it'd be interesting what comes out of it
I recently listened to a podcast with Tony Kay. He is working on something similar called GuardRails Pro which will be closed source
It would be great to have a free alternative
Looked up and listened the ClojureScript Podcast about GRP, sounds interesting.
Interesting times ahead, sounds like Clojure is getting mature :)
@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
https://github.com/metosin/malli/pull/252/commits/fecd792d02e20a9a22730ea0163b661c539eaa79
(-> (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"]}
full gist here: https://gist.github.com/ikitommi/06143540e6259323b95253e87e1ef710
Wow, super nice. Thanks!