This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-04
Channels
- # beginners (14)
- # boot (28)
- # chestnut (9)
- # cljsrn (18)
- # clojure (64)
- # clojure-conj (1)
- # clojure-dusseldorf (45)
- # clojure-finland (4)
- # clojure-gamedev (1)
- # clojure-greece (8)
- # clojure-italy (22)
- # clojure-russia (4)
- # clojure-spec (19)
- # clojure-uk (38)
- # clojurescript (49)
- # code-reviews (2)
- # component (12)
- # core-async (3)
- # cursive (3)
- # data-science (2)
- # events (4)
- # fulcro (394)
- # heroku (3)
- # hoplon (16)
- # immutant (11)
- # jobs (5)
- # lein-figwheel (1)
- # lumo (18)
- # off-topic (8)
- # om (11)
- # other-languages (1)
- # overtone (1)
- # pedestal (7)
- # portkey (62)
- # protorepl (1)
- # re-frame (40)
- # reagent (41)
- # ring-swagger (5)
- # spacemacs (5)
- # unrepl (5)
- # yada (12)
seems like I hit an interesting bug: direct-linking breaking a multispec : [...] foo is not a fn, expected predicate fn
and you can’t reproduce without direct linking?
well would be good to see a jira on that if you can build a reproducible case
I don’t think multimethod calls are direct linked
the line you have above is part of regex specs, not multispec
sorry, just guessing from too little info
managed to get spec working on clojurescript also after some searching/trying, but did not find any direct help on the internet. I’n now using a cljc file starting with `(ns m-venue.spec (:require [#?(:clj clojure.spec.alpha :cljs cljs.spec.alpha :default clojure.spec.alpha) :as s]))` and on clojure I only need to source path, for clojurescript i need to put it in the source paths and require it. Now I can use the same spec front and back-end 🙂.
cljs automatically rewrites the clojure namespace as the cljs one, so you shouldn’t actually need any of this afaik - just require the clojure ns
hi everyone, im trying to use :pre
and :post
to produce a more detailed error in run time
(defn person-name
[person]
{:pre [(if-not (s/valid? ::person person)
(throw (IllegalArgumentException. (s/explain ::person person)))
true)]
:post [(if-not (s/valid? string? %)
(throw (Exception. (s/valid? string? %)))
true)]}
(str (::first-name person) " " (::last-name person)))
(person-name 42)
;;=> CompilerException java.lang.IllegalArgumentException
val: 42 fails spec: :payment-gateway.util/person predicate: map?
:clojure.spec.alpha/spec :payment-gateway.util/person
:clojure.spec.alpha/value 42
;; works fine, s/explains works properly
(person-name {::first-name "Elon" ::last-name "Musk" ::email ""})
CompilerException java.lang.AssertionError: Assert failed: (if-not (s/valid? string? %) (throw (Exception. (s/valid? string? %))) false), compiling:(/Users/l/payment-gateway/src/payment_gateway/util.clj:31:1)
no explain data is printed :(
shouldn’t both of those pre and post be functions? I think they’re both getting evaluated at compilation time, not runtime