This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-07
Channels
- # announcements (7)
- # asami (3)
- # aws-lambda (2)
- # babashka (10)
- # beginners (30)
- # bristol-clojurians (3)
- # calva (13)
- # cider (26)
- # clj-kondo (6)
- # clojure (172)
- # clojure-europe (30)
- # clojure-italy (3)
- # clojure-nl (3)
- # clojure-serbia (9)
- # clojure-uk (64)
- # clojurescript (76)
- # conjure (9)
- # cursive (46)
- # data-science (1)
- # datomic (6)
- # emacs (13)
- # etaoin (1)
- # fulcro (27)
- # girouette (4)
- # jobs (1)
- # joker (2)
- # lsp (7)
- # malli (19)
- # meander (47)
- # off-topic (123)
- # pathom (6)
- # reitit (3)
- # remote-jobs (7)
- # reveal (37)
- # ring-swagger (2)
- # shadow-cljs (60)
- # specter (5)
- # startup-in-a-month (3)
- # tools-deps (21)
- # vim (4)
Hey, have issue with malli.error/humanize
, here is minimal example (cljs):
(let [Schema2 [:map
[:field keyword?]]
Schema [:map
[:foo int?]
[:bar [:or nil? Schema2]]]]
(malli.error/humanize
(malli/explain Schema {:foo 1
:bar {:field "test"}})))
Throws error: #object[Error Error: Vector's key for assoc must be a number.]
By the way, in clojure I get another error for same snippet:
Execution error (ClassCastException) at malli.error/-ensure (error.cljc:124).
class clojure.lang.Keyword cannot be cast to class java.lang.Number (clojure.lang.Keyword is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
When I call malli.util/update
on a schema, the properties of the key I update are dropped, is there any way to preserve them?
(malli.util/update
(malli.core/schema
[:map
[:a {:optional true}
int?]
[:b {:optional true} int?]])
:a identity)
;=> [:map [:a int?] [:b {:optional true} int?]]
Shall I open an issue?
util/update
is implemented by getting the value, then setting it
But it would be reasonable to expect that update
preserves the properties even if get
+ assoc
would not
I agree
I think an issue would at the very least be a better place to discuss how that should work
cool, added one here https://github.com/metosin/malli/issues/412
What would be a good way to "cut" a data structure using a schema that it partially adheres to? To keep what conforms to the schema and discard the rest? The best approach I can think of is to use m/explain and then use the data from :errors to run an update-in on the data. Is there a better way to do that? It seems to me like there should be.
Or perhaps the tentative coercer
https://github.com/metosin/malli/issues/404