clojure-spec

2022-11-11T13:43:17.783409Z

Is there a better way to accomplish this? I find in each place I am using conform, I want it to fail (throw) if it is invalid

(defn conform! [spec v]
  (let [conformed-value (s/conform spec v)]
    (if (s/invalid? conformed-value)
      (throw
        (ex-info
          "value did not conform to spec"
          (s/explain-data spec v)))
      conformed-value)))

Alex Miller (Clojure team) 2022-11-11T14:00:51.505939Z

Looks good to me

1