about summary refs log blame commit diff
path: root/users/grfn/bbbg/src/bbbg/util/spec.clj
blob: 89ac9266991471377e095757b7d781e9eee34b0d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                     
(ns bbbg.util.spec
  (:require [expound.alpha :as exp]
            [clojure.spec.alpha :as s]))

(defn assert!
  ([spec s] (assert! "Spec assertion failed" spec s))
  ([message spec x]
   (if (s/valid? spec x)
     x
     (throw (ex-info
             (str message
                  "\n"
                  (exp/expound-str spec x))
             (assoc (s/explain-data spec x)
                    ::s/failure
                    ::s/assertion-failed))))))