Not sure how useful the function schema checking is in real life (maybe for tooling?), but here’s the wip:
(require '[malli.generator :as mg])
(def check
(mg/function-checker
[:function
[1 [:=> [:cat :int] :int]]
[2 [:=> [:cat :int :int] [:int {:max 10}]]]]))
(check
(fn
([x] x)
([x y] (mod (+ x y) 10))))
; => nil
(check
(fn
([x] x)
([x y] (+ x y))))
;({:total-nodes-visited 18,
; :depth 6,
; :pass? false,
; :result false,
; :result-data nil,
; :time-shrinking-ms 0,
; :smallest [(0 11)],
; :malli.core/schema [:=> [:cat :int :int] [:int {:max 10}]]})
(check
(fn
([x y] (mod (+ x y) 10))))
;({:total-nodes-visited 0,
; :depth 0,
; :pass? false,
; :result "Wrong number of args (1) passed to: user/eval97462/fn--97463",
; :time-shrinking-ms 0,
; :smallest [(0)],
; :malli.core/schema [:=> [:cat :int] :int]})
hi, I search a little bit long before finding that representing date in malli could be easily done with inst? Is it a recommended approach? I have a doubt as I would expect to find a reference of that in the malli doc which I did not.
inst?
is ok, but see https://github.com/metosin/malli/issues/49
:not
merged in master:
(mg/sample [:not :string])
;([]
; #{}
; nil
; \$
; nil
; nil
; {#uuid"3565d7f3-5561-439f-9368-5bfdbd03fc8e" -2/3}
; ()
; [\^]
; [[-110317951337N \:] #{2.15625 R+3/qfp}])
Yes, I saw the PR, it was not completely enlightening. I understood something is missing, some of the proposal, but I did not understand there what is the recommend approach awaiting for that PR to be merged.
I keep the "`inst` is ok" part !