This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-10
Channels
- # announcements (8)
- # aws-lambda (4)
- # babashka (60)
- # beginners (65)
- # braveandtrue (5)
- # chlorine-clover (3)
- # cider (10)
- # clj-kondo (2)
- # cljdoc (2)
- # cljfx (32)
- # cljsrn (5)
- # clojure (198)
- # clojure-berlin (10)
- # clojure-europe (22)
- # clojure-france (1)
- # clojure-losangeles (33)
- # clojure-nl (3)
- # clojure-norway (22)
- # clojure-uk (35)
- # clojurescript (12)
- # code-reviews (14)
- # core-typed (1)
- # cursive (56)
- # datomic (13)
- # depstar (7)
- # emacs (1)
- # events (1)
- # figwheel-main (3)
- # fulcro (30)
- # graphql (15)
- # helix (1)
- # jobs (5)
- # juxt (6)
- # kaocha (14)
- # klipse (2)
- # malli (12)
- # off-topic (88)
- # portal (4)
- # re-frame (3)
- # reagent (5)
- # shadow-cljs (6)
- # specter (6)
- # sql (73)
- # tools-deps (15)
- # windows (4)
Guten morgen!
clojure-spec is weird; why doesn’t it complain about specific missing keys in a map? 😞
@synthomat did you mark them as :req?
explain-data
just says “something’s wrong” but doesn’t say “something’s wrong because username is missing”
(s/def ::username (s/and string? #(re-matches #"[a-z0-9_]{2,18}" %) ::not-reserved-name?))
(s/def ::form (s/keys :req-un [::username]))
input of {}
just gives this:
#:clojure.spec.alpha{:problems ({:path [],
:pred (clojure.core/fn [%] (clojure.core/contains? % :username)),
:val {},
:via [:linksourcer.web.accounts.validators/form],
:in []}),
:spec :linksourcer.web.accounts.validators/form,
:value {}}
whereas {:username "a"}
returns this:
#:clojure.spec.alpha{:problems ({:path [:username],
:pred (clojure.core/fn [%] (clojure.core/re-matches #"[a-z0-9_]{2,18}" %)),
:val "a",
:via [:linksourcer.web.accounts.validators/form
:linksourcer.web.accounts.validators/username],
:in [:username]}),
:spec :linksourcer.web.accounts.validators/form,
:value {:username "a"}}
Hmm it says at that at path location []
(root) the key`:username` is missing
Which is different form at [:username]
the value xyz
is invalid