This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-01
Channels
- # aws (1)
- # beginners (237)
- # boot (2)
- # calva (6)
- # cider (16)
- # clara (10)
- # clj-kondo (1)
- # cljs-dev (24)
- # clojure (29)
- # clojure-brasil (2)
- # clojure-dev (20)
- # clojure-europe (1)
- # clojure-italy (56)
- # clojure-japan (1)
- # clojure-nl (16)
- # clojure-spec (12)
- # clojure-uk (12)
- # clojurescript (24)
- # clojureverse-ops (3)
- # core-async (3)
- # cursive (21)
- # datascript (5)
- # datomic (82)
- # devops (5)
- # duct (14)
- # emacs (2)
- # fulcro (2)
- # jobs (6)
- # juxt (7)
- # kaocha (6)
- # leiningen (19)
- # luminus (3)
- # nrepl (51)
- # off-topic (208)
- # other-languages (1)
- # re-frame (8)
- # reagent (9)
- # remote-jobs (6)
- # shadow-cljs (37)
- # spacemacs (6)
- # testing (12)
- # tools-deps (25)
(spec/def :foo/bar int?)
(spec/def :baz/quux string?)
(spec/keys :req [...])
Is it possible to define a keys
spec such that the :foo/bar
key is required, but the :baz/quux
spec is validated for that specific key?
i.e. I want to override a spec without renaming the key
(rationale: :foo/bar
is a Datomic attribute. I cannot or don't want to rename it. And :foo/bar
has a existing spec, useful/correct 99% of the times)I have a hash-map
where the keys and values are used almost as a linked list {"a" "b", "b" "c", "c" "a"}
where a,b,c could be other strings. This is used in a map where I have a spec, but I don't know how to write a spec that says, let the keys and values be any ol' string.
Well that was easy...
One more question for now. I have a unique ID for many items. They are used throughout the speced map. When using generators, it doesn't understand the relationships between the IDs. Any way to enforce that?
https://github.com/reifyhealth/specmonstah is in this space
@david.folkner You can either (s/and (s/map-of ...) uniqueness-predicate)
or write your own generator. The former is "easy" if it's able to actually satisfy the criteria. The latter is harder but more likely to work.
Perfect. I'll take a look at making a generator, that will likely fit my application a bit better. I already have the functions to build up the data for my actual application, so a custom generator can leverage those.
for the latter, see gen/fmap
and/or gen/bind