This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-09
Channels
- # announcements (2)
- # babashka (33)
- # beginners (122)
- # bristol-clojurians (1)
- # calva (6)
- # chlorine-clover (3)
- # cider (45)
- # clara (10)
- # clj-kondo (3)
- # cljsrn (17)
- # clojure (80)
- # clojure-dev (21)
- # clojure-europe (86)
- # clojure-italy (5)
- # clojure-japan (5)
- # clojure-losangeles (7)
- # clojure-nl (5)
- # clojure-portugal (3)
- # clojure-uk (31)
- # clojurescript (30)
- # conjure (4)
- # core-async (29)
- # cursive (20)
- # data-science (25)
- # datomic (7)
- # duct (17)
- # figwheel-main (73)
- # fulcro (23)
- # jobs-discuss (36)
- # juxt (5)
- # kaocha (2)
- # lambdaisland (6)
- # luminus (5)
- # malli (17)
- # mount (10)
- # music (7)
- # off-topic (16)
- # re-frame (30)
- # ring (17)
- # rum (1)
- # shadow-cljs (10)
- # spacemacs (10)
- # specmonstah (4)
- # sql (45)
- # tools-deps (21)
- # xtdb (20)
re-implemented the schema visitor using walker: m/accept
is now a postwalk and and there is new m/find-first
to do lazy scanning for schemas. Though of doing a prewalk too, but coudn’t find any valid use case for such and would be more complex for schema extenders to add support for it. Not sure how useful the m/find-first
is and should merge this: https://github.com/metosin/malli/pull/216
(deftest find-first-test
(let [schema [:map
[:x int?]
[:y [:vector [:tuple
[:maybe int?]
[:or [:and {:salaisuus "turvassa"} boolean?] int?]
[:schema {:salaisuus "vaarassa"} false?]]]]
[:z [:string {:salaisuus "piilossa"}]]]]
(let [walked-properties (atom [])]
(is (= "turvassa" (m/find-first
schema
(fn [s _in _options]
(some->> s m/properties (swap! walked-properties conj))
(some-> s m/properties :salaisuus)))))
(is (= [{:salaisuus "turvassa"}] @walked-properties)))
(let [walked-properties (atom [])]
(is (= "vaarassa" (m/find-first
schema
(fn [s _in _options]
(some->> s m/properties (swap! walked-properties conj))
(some-> s m/properties :salaisuus #{"vaarassa"})))))
(is (= [{:salaisuus "turvassa"}
{:salaisuus "vaarassa"}] @walked-properties)))))
Hi all! Is there a possibility to merge definitions declaratively - for example in an edn definition given that the definitions to merge are defined in a registry?
I see I can do
[:and
[:ref :test/object]
[:ref :test/annotated]
[:map ....]]
but sadly this would test for all to be true rather than that later definitions override definitions from the former. Basically, I'm asking if there is something like mu/merge
in a declarative way@alpox nothing just now, but sounds like a good idea. Could you write an issue of that?
@ikitommi Done: https://github.com/metosin/malli/issues/217 thanks for the response!
what's the idiomatic way to specify a nonempty string in a schema? should I actually use a custom registry as in the README?
currently I'm doing this
(def nonempty-string
[:and
string?
[:fn {:error/message "should be nonempty string"}
(fn [x] (pos? (count x)))]])
one minor problem with that is that malli/explain
gives me two error messages: "should be string" and "should be nonempty string". I tried to set the :error/message
in the :and
instead to get only one error, but that didn't work
(I'm using the malli version that reitit 0.5.2 requires, i.e. 0.0.1-20200525.162645-15, if that matters)
@U65FN6WL9 [:string {:min 1}]
, will need to release new version to work with reitit
@ikitommi is there any chance you can release a new version of reitit
with the latest malli
?
another option for early adopters would be to release cutting-edge versions of malli under a separate namespace and artifact id (e.g., malli.pre-alpha
) so we can use that for our own code without fear of breaking reitit. that would also reduce the pressure to update reitit unless new malli functionality is actually needed there