This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
@bbloom > what’s the guidance for spec-ing pseudo-namespaced keywords? i’m thinking like datomic attributes when you do :customer/name
or something like that
I’ve actually been using it like this pretty much exclusively and I feel reading and referring to the spec becomes pretty trivial especially when you have multiple types that have the same name but the namespace disambiguates it (like multiple name
fields for instance :customer/name :business/name
)
Hey guys! Using clojure-spec for the first time to describe a db schema. Does this look okay or am I doing something obvious wrong?
(s/def ::first-name string?)
(s/def ::last-name string?)
(s/def ::username string?)
(s/def ::picture (s/nilable string?))
(s/def ::relationship-type int?)
(s/def ::friend (s/keys :req-un [::username ::last-name ::first-name ::picture ::id ::relationship-type]))
(s/def ::friends (s/coll-of ::friend :kind vector?))
@dvcrn :req-un
so when you pass in the data to be validated you can do
{:username "",
:last-name "",
:first-name "",
:picture "",
:relationship-type -1}
otherwise with :req you’d have to qualify the keywords.without :req-un you do something like this:
{:friend/username "",
:friend/last-name "",
:friend/first-name "",
:friend/picture "",
:friend/relationship-type -1}