This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-11
Channels
- # aleph (50)
- # announcements (20)
- # babashka (68)
- # beginners (70)
- # calva (25)
- # cider (1)
- # clj-kondo (10)
- # cljs-dev (3)
- # clojars (1)
- # clojure (113)
- # clojure-australia (7)
- # clojure-berlin (4)
- # clojure-europe (47)
- # clojure-italy (14)
- # clojure-nl (2)
- # clojure-norway (1)
- # clojure-serbia (5)
- # clojure-spec (11)
- # clojure-uk (8)
- # clojurescript (16)
- # community-development (2)
- # conjure (2)
- # cursive (15)
- # data-oriented-programming (35)
- # datahike (12)
- # datascript (5)
- # datomic (13)
- # duct (7)
- # fulcro (21)
- # graalvm (94)
- # graphql (1)
- # helix (4)
- # honeysql (19)
- # jackdaw (8)
- # jobs (2)
- # jobs-rus (1)
- # leiningen (1)
- # malli (32)
- # missionary (1)
- # mount (1)
- # off-topic (40)
- # perun (2)
- # portal (7)
- # reitit (10)
- # rewrite-clj (26)
- # shadow-cljs (90)
- # spacemacs (29)
- # sql (17)
- # tools-deps (49)
- # wasm (1)
- # xtdb (26)
@l0st3d & everyone else, opinions on :m/default
or :malli/default
?
[:multi {:dispatch :type}
["object" [:map-of :keyword :string]]
[:m/default :string]]
vs:
[:multi {:dispatch :type}
["object" [:map-of :keyword :string]]
[:malli/default :string]]
… same could be used for extra-keys in maps, e.g. :m/extra
vs :malli/extra
. Personally fond of the :m
.(def valid?
(m/validator
[:multi {:dispatch :type}
["object" [:map-of :keyword :string]]
[:m/default :string]]))
(valid? {:type "object", :key "1", :value "100"})
; => true
(valid? "SUCCESS!")
; => true
(valid? :failure)
; => false
That would definitely solve my problem and make my code easier to read ... it get's my vote ... many thanks for the impressively fast feedback.
Hehe, sometimes I dream about creating a sub-community of "Clojurists against too much abbreviation"
😉 ... I think it's not about abbreviation, but scope ... :m/
is a public namespace that may be being used by an application and may well be a target in that multi dispatch, whereas ::m/
is scoped to malli.core
and therefore shouldn't have meaning in your application - so it's fine to use as a default ... I think where clojure pushes back against brevity it tends to be for reasons of applicability in different contexts - which makes it a more generally useful language
Hello, how to attach custom error message to seqexp? For example:
(malli.error/humanize
(malli/explain
[:map
[:items
[:+
{:error/message "Items must not be empty"}
[:map [:foo string?
:bar int?]]]]]
{:items []}))
looks like the :error/message
is in the wrong place:
(me/humanize
(m/explain
[:map
[:items
[:+
[:map {:error/message "Items must not be empty"}
[:foo string?
:bar int?]]]]]
{:items []}));; => {:items [["Items must not be empty"]]}
And if I put error inside :map, then all other map validation errors replaced with that one, even ‘missing key’ is becomes ‘items must not be empty’.
@emccue try https://malli.io/?value=%5B%3Aa%20%3Ab%20%7B%3Aname%20%22kikka%22%7D%5D&schema=%5B%3Avector%20%0A%20%5B%3Aor%20%0A%20%20%5B%3Aenum%20%3Aa%20%3Ab%5D%0A%20%20%5B%3Amap%20%5B%3Aname%20%3Astring%5D%5D%5D%5D
the http://malli.io is not updated for 0.3.0, so no :alt
there yet. PR welcome to update deps
(looped back to this, i'm probably wrong and got confused by the "inferred schema" part and also my bad memory)
updated http://malli.io, with few sequence samples (args & hiccup)