This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-24
Channels
- # announcements (3)
- # babashka (23)
- # beginners (35)
- # cider (3)
- # clara (3)
- # clj-kondo (14)
- # cljdoc (1)
- # cljs-dev (1)
- # clojure (82)
- # clojure-austin (9)
- # clojure-europe (5)
- # clojurescript (23)
- # conjure (62)
- # cursive (73)
- # defnpodcast (1)
- # emacs (3)
- # ethereum (1)
- # gratitude (1)
- # hyperfiddle (12)
- # introduce-yourself (1)
- # leiningen (2)
- # lsp (44)
- # malli (7)
- # polylith (2)
- # portal (17)
- # re-frame (5)
- # reitit (3)
- # sci (8)
- # shadow-cljs (5)
- # tools-build (11)
Hi, I'm getting a strange error when running the http://malli.io example of "Pet" in Clojure (not Clojurescript). Code here:
1
(def PetMalli
[:schema {:registry {"Pet" [:map
[:type keyword?]
[:name string?]]
"Cat" [:merge
"Pet"
[:map
[:type [:= "Cat"]]
[:huntingSkill [:enum {:description "The measured skill for hunting"}
:clueless, :lazy, :adventurous, :aggressive]]]]
"Dog" [:merge
"Pet"
[:map
[:type [:= "Dog"]]
[:packSize [:int {:min 0,
:default 0
:description "the size of the pack the dog is from"}]]]]}}
[:multi {:dispatch :type} "Cat" "Dog"]])
(m/validate PetMalli {:type "Cat", :name "Viivi", :huntingSkill :adventurous})
Message: Execution error (ExceptionInfo) at malli.core/-fail! (core.cljc:136). :malli.core/invalid-schema {:schema :merge}
Could anyone give me some pointers? We want to use :merge for some inheritance-like constraints in our schema, which is very similar to the "Pet" example.
Merge is in another registry. You need to merge it into the registry you're creating. It's in malli util, I think