This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-10
Channels
- # announcements (1)
- # babashka (5)
- # beginners (44)
- # calva (45)
- # cider (8)
- # clj-kondo (9)
- # cljdoc (12)
- # clojars (7)
- # clojure (20)
- # clojure-czech (1)
- # clojure-dev (26)
- # clojure-europe (24)
- # clojure-france (8)
- # clojure-uk (1)
- # clojurescript (12)
- # conjure (8)
- # datascript (10)
- # fulcro (7)
- # leiningen (2)
- # malli (19)
- # meander (5)
- # off-topic (113)
- # pathom (3)
- # precept (4)
- # re-frame (13)
- # reagent (19)
- # reitit (3)
- # rewrite-clj (69)
- # shadow-cljs (9)
- # spacemacs (16)
- # tools-deps (1)
- # vim (1)
- # xtdb (10)
@ikitommi I'm reading through the Malli README and found a couple of spelling improvements: Homogenous -> Homogeneous
And this sentence: > You can also decomplected maps keys and values using registry references. seems to be grammatically a bit off
toyed with the declarative schema transformations, which might be useful when defining schemas in EDN:
(require '[malli.core :as m])
(require '[malli.util :as mu])
(require '[malli.error :as me])
(def registry (merge (m/default-schemas) (mu/schemas)))
(def XZ
(m/schema
[:select-keys
[:merge
[:map [:x int?]]
[:map [:y int?]]
[:map [:z int?]]]
[:x :z]]
{:registry registry}))
XZ
; [:select-keys
; [:merge
; [:map [:x int?]]
; [:map [:y int?]]
; [:map [:z int?]]]
; [:x :z]]
;; get the effective schema
(m/deref XZ)
; [:map [:x int?] [:z int?]]
;; internally uses the pre-computed effective schema
(-> XZ
(m/explain {:x 1})
(me/humanize))
; {:z ["missing required key"]}
I was wondering, does malli also do the destructuring that spec does e.g. on a sequential regex schema? (s/cat etc)
not yet, the internal api works, but not integrated into malli.core: https://github.com/metosin/malli/issues/180
… and https://github.com/metosin/malli/issues/241 after that.
When creating a validator, how do I use non-core functions in a :fn
? Specifically, I want to use clojure.string/blank?
@zilti :fn
takes any function as unquoted, so [:fn clojure.string/blank?]
. They don't serialize correctly, but work on the same runtime. If you use sci, you need to add custom bindings for the function for all runtimes. I believe str/blank?
is part of sci default bindings, so [:fn 'str/blank?]
should work too.
:string
has good default error messages: https://github.com/metosin/malli/blob/master/test/malli/error_test.cljc#L262-L283