This repository implements instrumentation for malli with a very similar API to clojure.spec.alpha's instrumentation.
Malli is awesome, but instrumentation doesn't seem to be implemented yet, so I scratched my own itch. There are libraries like aave offering similar features on top of malli. However, to the best of my knowledge this is the only library that uses the same instrumentation API as clojure.spec.alpha, where instrumentation occurs in a dedicated command, and with no special defn
wrappers.
This library is in a very early stage. It works but is not yet intended for production use. Please feel free to suggest new features or report any bugs in the issue tracker.
Using deps.edn and git dependencies:
{setzer22/malli-instrument {:git/url "https://github.com/setzer22/malli-instrument.git" :sha "<latest master branch sha>"}}
Being in a very early stage, this library is not published in any maven repository, so other forms of distribution are currently unsupported.
(require '[malli.core :as m])
(require '[malli-instrument.core :as mi])
(m/=> foo [:=> [:cat int? int?] string?])
(defn foo [x, y]
(+ x y))
(mi/instrument-all!)
(foo 1 2) ;; Throws ex-info with message "Function returned wrong output"
;; and data {:error ["should be a string"], :value 3}
Currently, this library offers limited support for emacs (more specifically Spacemacs). This enables the following features:
clojure-mode
: , e k
(instrument all functions) and , e K
(unstrument all functions), e b
(i.e. cider-eval-buffer
)To enable this configuration, copy the contents of spacemacs-setup.el in your .spacemacs
' dotspacemacs/user-config
function, or any other equivalent initialization code.
Can you improve this documentation? These fine people already did:
setzer22 & Yuri Vendruscolo da SilveiraEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close