clojure-europe

For people in Europe... or elsewhere... UGT https://indieweb.org/Universal_Greeting_Time
slipset 2020-09-10T05:11:23.248400Z

God morgen!

☕ 2
synthomat 2020-09-10T05:40:16.249100Z

goedemorgen!

2020-09-10T06:43:12.249400Z

bonjour !

plexus 2020-09-10T07:53:44.249800Z

Guten Morgen!

2020-09-10T07:54:35.250Z

ay up

raymcdermott 2020-09-10T08:17:06.250200Z

dag

borkdude 2020-09-10T08:18:11.250400Z

yo

thomas 2020-09-10T08:25:28.250600Z

moin moin

2020-09-10T12:17:09.250900Z

having a lot of fun with x/by-key and x/reduce today

ordnungswidrig 2020-09-10T13:13:39.251100Z

Guten morgen!

raymcdermott 2020-09-10T14:56:14.252100Z

since we're talking functions - enjoying the function, new since 1.10 read+string

synthomat 2020-09-10T20:29:58.253100Z

clojure-spec is weird; why doesn’t it complain about specific missing keys in a map? 😞

synthomat 2020-09-10T20:30:16.253300Z

am I holding it wrong?

dominicm 2020-09-10T20:36:12.253700Z

@synthomat did you mark them as :req?

synthomat 2020-09-10T20:38:18.253900Z

yes

synthomat 2020-09-10T20:38:43.254500Z

explain-data just says “something’s wrong” but doesn’t say “something’s wrong because username is missing”

synthomat 2020-09-10T20:39:42.254800Z

(s/def ::username (s/and string? #(re-matches #"[a-z0-9_]{2,18}" %) ::not-reserved-name?))
(s/def ::form (s/keys :req-un [::username]))

synthomat 2020-09-10T20:40:01.255200Z

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 {}}

synthomat 2020-09-10T20:41:35.255700Z

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"}}

ordnungswidrig 2020-09-10T21:00:35.256100Z

Hmm it says at that at path location [] (root) the key`:username` is missing

ordnungswidrig 2020-09-10T21:01:48.256800Z

Which is different form at [:username] the value xyz is invalid

dominicm 2020-09-10T21:30:31.257500Z

^. :req is a map property, rather than a property of a key.