This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-28
Channels
- # ai (1)
- # beginners (239)
- # bitcoin (1)
- # boot (4)
- # cider (5)
- # clara (3)
- # cljs-dev (16)
- # cljsjs (5)
- # cljsrn (1)
- # clojure (152)
- # clojure-android (3)
- # clojure-dev (3)
- # clojure-greece (4)
- # clojure-italy (5)
- # clojure-spec (14)
- # clojure-uk (24)
- # clojurescript (81)
- # data-science (1)
- # datomic (47)
- # devcards (34)
- # docs (3)
- # emacs (6)
- # ethereum (1)
- # events (9)
- # flambo (5)
- # fulcro (11)
- # graphql (1)
- # immutant (3)
- # lein-figwheel (2)
- # leiningen (2)
- # luminus (6)
- # lumo (90)
- # off-topic (25)
- # proton (2)
- # re-frame (44)
- # reagent (5)
- # ring (7)
- # ring-swagger (11)
- # shadow-cljs (11)
- # spacemacs (6)
- # vim (13)
- # yada (25)
Hi! is there a (short) way to reference a spec defined in a different namespace?
(ns a.b.c
(:require [cljs.spec.alpha :as s]))
(s/def ::foo int?)
;;; in a different ns
(ns a.d
(:require [cljs.spec.alpha :as s])
(s/valid :a.b.c/foo 10)
Is there a way to avoid typing the fully qualified :a.b.c/foo by using :require :as ?(require [a.b.c :as a-really-short-name-that-doesn't-take-a-while-to-read]) ::a-really-short-name-that-doesn't-take-a-while-to-read/foo
@shark8me
Hello. I have a function: (defn f [m])
. I expect m
to be a map containing a value unter the key :name
. The value has to be a keyword. How do I spec this function using (s/fdef f :args #!%&)
? What do I have to put in :args
?
@witek If I understand your problem, then s/keys
should work just fine:
(s/def ::name keyword?)
(s/valid? (s/keys :req-un [::name]) {:name :john}) ;=> true
(s/valid? (s/keys :req-un [::name]) {:name "john"}) ;=> false
Or rather for the function:
(defn f [m]
(:name m))
(s/fdef f
:args (s/cat :m (s/keys :req-un [::name])))