Fork me on GitHub

there are some gaps in the malli->clj-kondo integration, any insights welcome: marked with ;;??



(require '[malli.clj-kondo :as mc])

   [:id string?]
   [:tags {:optional true} [:set keyword?]]
     [:street string?]
     [:city string?]
     [:zip {:optional true} int?]
     [:lonlat [:tuple double? double?]]]]])
;{:op :keys
; :opt {:tags :set}
; :req {:id :string
;       :address {:op :keys
;                 :opt {:zip :int}
;                 :req {:street :string
;                       :city :string
;                       :lonlat [:double :double]}}}}


btw, would be great if clj-kondo supported :min and :max for numbers & collections. nice demo about “more than types”, something like:

(ms/defn times :- :int
  [x :- [:int {:min 3}]]
  (* x x))

(times 2)
;; ^:--- clj-kondo error of "number should be at least 3"


Don't know if this a common enough problem in function calls. I haven't encountered this much I think. If there's a domain specific need to check this, one can also write a hook


ok. just wondering as clj-kondo already supports map-op-syntax, so if :int could be defined as {:op :int}, it would allow adding easily new keys that would be easy to check, e.g. malli could emit {:opt :int, :min 3} from the example. Not sure how useful that would be, but: • number min & max might be easy to implement on clj-kondo side? • would be a great demo, as you can’t easily present these with simple typed langs liike Java


but, I don’t need this for real, just thinking aloud about a kick-ass demo 🙂


it has :pos-int and :nat-int which map to the clojure predicates. it basically only has that which exists as predicates in clojure 1.9+


@ikitommi Feel free to try out things with the clj-kondo type system. You can build a custom clj-kondo for your demo possibly


it's all in clj-kondo.impl.types


thanks, might give it a shot.


@ikitommi Ah, I can see why your approach might be problematic: So the literal value is mapped to a type tag. And then during checking that is resolved very cheaply, not executing any predicates, but just checking a keyword identity or a super simple graph, e.g. a pos-int is also an int

👀 3

so the literal value is erased as it were


Hi guys, just getting my feet wet with malli. Quick question: when I try to transform a map to JSON-Schema, all the map's keywords are still Clojure keywords and thus invalid syntax in JSON-Schema. Sure, I could post-process it, but is this on purpose? What's the best way to get proper JSON-Schema?


@marcus.poparcus I think it would be better to emit strings directly. PR Welcome.