God morgen!
goedemorgen!
bonjour !
Guten Morgen!
ay up
dag
yo
moin moin
having a lot of fun with x/by-key and x/reduce today
Guten morgen!
since we're talking functions - enjoying the function, new since 1.10 read+string
clojure-spec is weird; why doesn’t it complain about specific missing keys in a map? 😞
am I holding it wrong?
@synthomat did you mark them as :req?
yes
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
^. :req is a map property, rather than a property of a key.