Specification is much more powerful than static typing plus you also get validation, instrumentation and generative testing – clojure.spec (by Rich Hickey)
Example (spec for URIs)
ns example.specs
(:require #?(:clj [clojure.spec :as s]
(:cljs [cljs.spec :as s])
:as str]))
[clojure.string ;; URI spec.
def uri?
(string? #?(:clj #(try (do (java.net.URI. %) true) (catch Exception e false))
(s/and :cljs #(= (str/replace (js/encodeURI %) "%25" "%") %))))
;; e.g. Call as follows:
"https://www.google.nl/url?q=https://www.reddit.com/r/Clojure/comments/4kutl7/clojurespec_guide/&sa=U&ved=0ahUKEwic2v3-r6DQAhVBGsAKHcrVCZMQFggUMAA&usg=AFQjCNHs0DmF1uNIw9BYUK7pqpgp5HEbow") (s/valid? uri?
Videos
- o Introducing clojure.spec (by Arne Brasseur);
- o Agility & Robustness: Clojure spec (by Stuart Halloway);
- o Clojure spec Screencast: Leverage (by Stuart Halloway);
- o Clojure spec Screencast: Testing; (by Stuart Halloway)
- o Clojure spec Screencast: Customizing Generators (by Stuart Halloway);
- o Introduction to clojure.spec (by Lambda Island);
- o clojure.spec (by David Nolen).