This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-12
Channels
- # admin-announcements (1)
- # arachne (3)
- # cider (11)
- # cljsrn (5)
- # clojure (26)
- # clojure-android (10)
- # clojure-greece (8)
- # clojure-russia (5)
- # clojure-spec (7)
- # clojure-uk (3)
- # clojurescript (16)
- # clojurex (38)
- # core-async (1)
- # css (3)
- # cursive (42)
- # dirac (2)
- # hoplon (28)
- # keechma (1)
- # lein-figwheel (2)
- # leiningen (1)
- # mount (3)
- # om (132)
- # onyx (46)
- # re-frame (53)
- # reagent (17)
- # spacemacs (7)
- # specter (50)
- # untangled (2)
- # yada (3)
Hi Everyone. How do you name aggregate stuff with namespaced keywords? Say I have a map that would look like this without namespaced keywords
{:first-name "John"
:last-name "Doe"
:address
{:street "Example Street"
:street-number "413"
:city "Example city"}}
The keys at the first level might be namespaced like :customer/first-name and :customer/last-name, but how would I name the keys inside the address map?{:customer/first-name "John"
:customer/last-name "Doe"
:customer/street "Example Street"
:customer/street-number "413"
:customer/city "Example city"
:customer/address-fields #{:customer/street
:customer/street-number
:customer/city}}
@hiredman: thanks. when would you say it's appropriate to create a "child namespace", e.g. :customer.address/*
?
What is more idiomatic,
(ns work.invoice
(:require [clojure.spec :as s]))
(s/def ::invoice (s/keys :req [::number ::date ::amount]))
or
(ns work.core
(:require [clojure.spec :as s]
[work.invoice :as i))
(s/def ::invoice (s/keys :req [::i/number ::i/date ::i/amount]))
? The first is less typing work, but I don't really like :work.invoice/invoice
as a spec name. Maybe this?
(ns work.invoice
(:require [clojure.spec :as s]))
(s/def :work/invoice (s/keys :req [::number ::date ::amount]))
Does anyone know of a way to compose key sets? e.g something like (s/merge ::foo ::bar)
edit: and
works for validation, but does not yield a working generator...