If I have defined the following record:
(defrecord Person [name id])
and the following:
(s/def ::name string?)
(s/def ::id int?)
(s/def ::person (s/keys :req-un [::name ::id]))
How can I ensure that you can't create a Person that does not conform to the ::person spec? In other words, the following should throw an exception:
(->Person "Fred" "3")
I tried:
(s/fdef ->Person :ret ::person)
but calling:
(->Person "Fred" "3")
does not raise an exception.
However:
(s/conform ::person (->Person "Fred" "3"))
does yield the expected:
:clojure.spec/invalid
Thanks