This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-21
Channels
- # aws (2)
- # bangalore-clj (14)
- # beginners (20)
- # boot (20)
- # cider (7)
- # cljs-dev (38)
- # cljsrn (13)
- # clojure (487)
- # clojure-argentina (3)
- # clojure-dev (15)
- # clojure-gamedev (4)
- # clojure-italy (3)
- # clojure-poland (1)
- # clojure-russia (1)
- # clojure-spec (25)
- # clojure-uk (47)
- # clojurescript (127)
- # datomic (125)
- # defnpodcast (1)
- # hoplon (27)
- # jobs (4)
- # lein-figwheel (2)
- # leiningen (1)
- # luminus (5)
- # off-topic (3)
- # om (25)
- # onyx (9)
- # parinfer (3)
- # pedestal (20)
- # planck (65)
- # re-frame (43)
- # reagent (4)
- # remote-jobs (1)
- # ring-swagger (2)
- # rum (9)
- # spacemacs (1)
- # unrepl (37)
- # vim (1)
@danieleneal @alex - gave a shot at the CLJ-2116: https://github.com/clojure/spec.alpha/pull/1. Idea is to support a optional conforming callback
for conform & explain, allowing specs to be separated from conforming. Would be used like this:
(deftest conforming-callback-test
(let [string->int-conforming
(fn [spec]
(condp = spec
int? (fn [_ x _]
(cond
(int? x) x
(string? x) (try
(Long/parseLong x)
(catch Exception _
::s/invalid))
:else ::s/invalid))
:else nil))]
(testing "no conforming callback"
(is (= 1 (s/conform int? 1)))
(is (= ::s/invalid (s/conform int? "1"))))
(testing "with conforming callback"
(is (= 1 (s/conform int? 1 string->int-conforming)))
(is (= 1 (s/conform int? "1" string->int-conforming))))))
same thing out of the repl too - lein test
just hangs (running generative tests via clojure.test.check in my normal test suite)
I did verify that I could generate data for all the (s/def)
expressions individually - that seems to work
@scaturr did you try generating (s/cat :type ::type :error? ::error? :payload (s/? ::payload))
as well?
I'm trying this out too
can't reproduce; check
ran fine for me
probably 0.10.0-alpha2
well I'd certainly like to know what the difference is, but I don't think it matters enough to look into 😕
but if you figure it out, let me know 🙂
@ikitommi noted. I'm not going to do anything with it until I get a chance to ask Rich about it
hello people, for those looking at how to do coercion with specs, spec-coerce
leverages your spec definitions to coerce value types 🙂 https://github.com/wilkerlucio/spec-coerce