This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-25
Channels
- # beginners (32)
- # boot (1)
- # cljs-dev (25)
- # cljsrn (1)
- # clojure (35)
- # clojure-dev (6)
- # clojure-nl (4)
- # clojure-russia (12)
- # clojure-spec (13)
- # clojure-switzerland (2)
- # clojurescript (63)
- # cursive (9)
- # datomic (18)
- # dirac (32)
- # graphql (6)
- # luminus (8)
- # off-topic (18)
- # pedestal (5)
- # protorepl (1)
- # re-frame (30)
- # remote-jobs (5)
- # untangled (61)
- # yada (7)
I know spec is maybe too new for idioms to develop but is there a clear answer to having :x.specs.user/email
, :x.specs.user/password
and then :x.specs.user/user
for the whole user entity or is :x.specs/user
a better name for the "entity", what's everyone's preferences here?
(ns x.specs.user
(:require [clojure.spec.alpha :as s]))
(s/def ::username string?)
(s/def ::password string?)
(s/def ::user ;;or is :x.specs/user better?
(s/keys :req [::username ::password]))
I'm personally convinced x.specs/user
is clearly better than ::user which expands to :x.specs.user/user
, just trying to get a second opinion before imposing my will on others.
We have been doing something similar to :x.specs.user/user
in your example. It seemed like a natural choice at first and it quickly became a shared language across the team.
I’m also not sure if this will evolve into an idiom but surely has made the communication in our team much easier.
There’s an interesting side-effect that’s been great for the specifics of our project. We receive entity names from a remote system in a simple string. We can then convert the string into :x.specs.<string>/<string>
and boom: we have our spec 🙂
@lucascs awesome yeah that's basically what I'm going for with the overall project set up but is there a reason you go with :x.specs.<string>/<string>
instead of :x.specs/<string>
for the composite entity at the end of the file? Because what you're saying could be done with either of those options just as easily right? (Sorry to painfully over analyze small details here)
Indeed it could. In practice the reasoning behind our choice was purely aesthetics. Kind of “everything related to the user entity is namespaced with :x.specs.user
.” Otherwise we would need to always have the entity itself as a bit of an exception (defining it with :x.specs/user
instead of autoexpanding with ::user
).