This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-05
Channels
- # announcements (8)
- # asami (70)
- # babashka (28)
- # beginners (163)
- # calva (7)
- # cider (15)
- # clj-kondo (47)
- # cljs-dev (45)
- # clojars (2)
- # clojure (56)
- # clojure-europe (24)
- # clojure-italy (1)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-spec (2)
- # clojure-uk (53)
- # clojurescript (46)
- # data-oriented-programming (15)
- # data-science (10)
- # datahike (2)
- # defnpodcast (1)
- # depstar (27)
- # emacs (35)
- # figwheel-main (28)
- # fulcro (38)
- # girouette (1)
- # graphql (16)
- # jobs-discuss (3)
- # kaocha (9)
- # keechma (2)
- # leiningen (6)
- # lsp (87)
- # malli (19)
- # membrane (16)
- # pathom (4)
- # re-frame (11)
- # shadow-cljs (25)
- # spacemacs (2)
- # testing (12)
- # tools-deps (14)
- # tree-sitter (4)
- # xtdb (20)
quick question with regards to properties. I’m trying to put some properties into my schemas, but can’t seem to be getting them back. What am I doing wrong here?
; malli 0.3.0:
; [malli.registry :as registry]
(def registry
(registry/composite-registry
malli/default-registry
{:common/single-line [:re {:bubu :lala} #"^[^\r\n]*$"]}))
(malli/properties :common/single-line {:registry registry})
=> nil
Expected: {:bubu :lala}
@beders oh, that’s not good. registry interally wraps the registered schema instances into :malli.core/schema
, which is an eager reference type. When you pull out an instance schema from a registry, you get the reference back. it mostly a pass-through, e.g. calling -validator
to the reference return the validator of the referenced schema. But: for some reason, the current impl returns the reference properties and options if asked. I think it’s a bad feature, should be changed.
(def registry
(mr/composite-registry
m/default-registry
{:common/single-line [:re {:bubu :lala} #"^[^\r\n]*$"]}))
(-> (m/schema :common/single-line {:registry registry})
(doto prn)
(m/deref)
(doto prn)
(m/properties))
;:common/single-line
;[:re {:bubu :lala} #"^[^\r\n]*$"]
;=> {:bubu :lala}
workaround for now:
(def registry
(mr/composite-registry
m/default-registry
{:common/single-line [:re {:bubu :lala} #"^[^\r\n]*$"]}))
(defn schema [?schema]
(m/deref (m/schema ?schema {:registry registry})))
(schema :common/single-line)
; => [:re {:bubu :lala} #"^[^\r\n]*$"]
Thanks for the help and explanation. It would be good to have some documentation around explaining instances vs. Schema. I’m still confused 🙂
Is there a standard body of localized error messages for humanize
?
@ikitommi What about making a plugin for malli which inspects clojure.spec specs and emits a malli schema from it? ;) Might help people migrating to malli

Hi, trying to wrap my mind around how these two examples can/will differ over time when it comes to value generation
(def CDN1
[:map
[:images [:vector string?]]])
(def CDN2
[:map
[:images [:sequential string?]]])
(malli.generator/generate CDN1)
(malli.generator/generate CDN2)
-- i guess the question is - will they defer ? and if so how ? in my testing the generated values are very similar@dviramontes in clojure sequential can also be a list
or lazy-seq
for example, not always a vector, but that should not affect equality semantics

it seems the generator doesn't really generate anything other than vectors at the moment (by experimentation) but it could
gotcha, thanks very much!