This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-29
Channels
- # aws (2)
- # bangalore-clj (2)
- # beginners (36)
- # boot (10)
- # cider (9)
- # cljs-dev (19)
- # clojure (47)
- # clojure-russia (4)
- # clojure-spec (18)
- # clojure-uk (4)
- # clojurescript (71)
- # core-async (20)
- # core-logic (2)
- # css (3)
- # cursive (5)
- # data-science (15)
- # datomic (7)
- # emacs (13)
- # figwheel (4)
- # klipse (1)
- # luminus (5)
- # lumo (1)
- # off-topic (33)
- # re-frame (17)
- # shadow-cljs (1)
- # spacemacs (5)
- # specter (21)
- # unrepl (1)
- # vim (7)
Quick sanity check. I think this code should stub a function (in second case). It does on CLJ but doesn't on CLJS.
(defn add2 [a b] 1.1)
(s/fdef add2 :args (s/cat :a int? :b int?) :ret int?)
(println ::a (add2 1 2))
(stest/instrument `add2 {:stub #{`add2}})
(println ::b (add2 1 2))
(stest/unstrument `add2)
(println ::c (add2 1 2))
Am I doing something obviously wrong?
Is it possible to do ‘cross’ specification/validation with spec? If I have a map
{:a "even"
:b 2}
Where say :b
should be odd?
if :a
is "odd"
and vice versa?@eoliphant Perhaps treat them as separate cases and combine with spec/or
.
Hi, is there a way to generate self contained specs? I want to turn a swagger.json into a spec and run it on some data at runtime, and it looks like that requires eval with the way the spec registry currently works?
Oh, and https://clojure.github.io/core.specs.alpha/ appears to be broken, I arrived there from the overall clojure api page https://clojure.org/api/api
This is a known issue in the doc build process
Ok, just wanted to let you know. Any insights into the other problem? I feel pretty dirty if I have to fiddle with global mutable state just to get some spec validation working...
If i want to use spec in order to pass the user of my application a error msg how would i do that? Is there a place to override the error msg with a custom one?
Does that even fit with the rational? Like if i have a command line app and i want to validate the input and send back an error msg, would spec fit into?
The idea is to use the explain-data result and map it to whatever error messages you want in your app @drewverlee
@drewverlee Perhaps https://github.com/alexanderkiel/phrase would be a good fit?
But yes, if your specs are fairly simple, it might be easies to just map explain-data to error messages. It gets a little trickier if your specs are more deeply nested
@bbrinck phrase is in the spirit of what i want. Its odd i couldn't search it down.