Fork me on GitHub

@drewverlee I think the human error messages also need to include a location which is separate from their spec position. Sometimes you need to do validation across keys for humans, but place the error message on a particular key (password & password_confirm must match, but if they don't, the error is in password_confirm)


i find them noisy and like that test.chuck turns them off when using the checking macro

Drew Verlee16:11:02

Is there a rational for the :reason key in the problem map produced by spec/explain-data?. I cant find any discussion on it

Drew Verlee20:11:42

is there a function that you can call on a spec to get the code for the spec?

(s/data some-spec) 
;;=> (s/def ::some-spec string?)


(s/form some-spec) in your example should work @drewverlee

Drew Verlee20:11:58

It seems to only return part of the spec.

(s/def ::kid (s/keys ::req [::name]))
(s/form ::kid) 
;;> (spec/keys)


I think that keys spec is invalid


try :req instead of ::req

Drew Verlee21:11:12

Hmm, how about something similar for spec functions? those defined using fdef?


(s/form `foo)
where foo is your function

Drew Verlee16:11:52

How does that work? backtick stops evaluation of things and qualifies their namespace. Why does that help?


> However, symbols used within a syntax quote are fully resolved with respect to the current namespace


(defn foo [x] x)
=> #'sandbox.core/foo
=> #object[sandbox.core$foo 0x111da369 "[email protected]"]
=> sandbox.core/foo
(type foo)
=> sandbox.core$foo
(type `foo)
=> clojure.lang.Symbol

Drew Verlee16:11:20

gotcha. I was actual experiencing another mis understanding the same time concerning lists.


s/fdef is using s/def “behind the scenes” to register the spec to the function symbol, so you can use the function symbol to resolve the spec (instead of a namespaced keyword)