clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
tvalerio 2020-09-14T17:42:47.125600Z

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?