Fork me on GitHub
#clojure-spec
<
2020-09-14
>
tvalerio17:09:47

Hi! I have this spec in a namespace and a test so I can validate it:

(ns develop.rates)

(defn- valid-rate-intervals?
  [rate]
  false)

(s/def ::rates (valid-rate-intervals?))
(ns develop.rates-test
   (:use clojure.test)
   (:require
      [clojure.spec.alpha :as s]
      [develop.rates :refer :all])

(deftest should-test-a-rate
  (testing "Test a rate"
    (let [result (s/explain-data :develop.rates/rates {:rate "test"})]
      (prn "result: " result))))
Why can’t I use the spec like ::rates instead of the example in the code? If I try yo use it, I get an unable to find spec error. Also, when I watch the result of explain-data I can see that it begins with:
#:clojure.spec.alpha{:problems...
And not like:
#:rates{:problems...
As I saw in the examples. I’m trying to verify which function got error to return a proper error message but I’m getting a hard time to do so. Trying Spec for the first time. How could I do that?