This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-27
Channels
- # announcements (7)
- # aws (1)
- # beginners (42)
- # calva (65)
- # clj-kondo (5)
- # cljs-dev (11)
- # clojure (69)
- # clojure-australia (7)
- # clojure-dev (4)
- # clojure-europe (9)
- # clojure-gamedev (2)
- # clojurescript (2)
- # conjure (4)
- # cursive (1)
- # data-science (1)
- # datomic (8)
- # events (1)
- # fulcro (35)
- # graalvm-mobile (40)
- # introduce-yourself (1)
- # lsp (26)
- # malli (14)
- # mathematics (2)
- # missionary (5)
- # nextjournal (4)
- # off-topic (4)
- # polylith (10)
- # shadow-cljs (5)
- # test-doc-blocks (1)
- # tools-build (24)
- # tools-deps (1)
- # xtdb (12)
allowing schema registry to be swapped without compiler/jvm-options: https://github.com/metosin/malli/pull/583. There would be a "strict"
mode too, if this is too loose for someone. But might be better for the 90% of cases?
(require '[malli.core :as m]
'[malli.util :as mu]
'[malli.registry :as mr]
'[malli.generator :as mg])
;; look ma, just works
(mr/set-default-registry!
(mr/composite-registry
(m/default-schemas)
(mu/schemas)))
(mg/generate
[:merge
[:map [:x :int]]
[:map [:y :int]]])
; => {:x 0, :y 92}
comments welcome.your sample could be:
(mr/set-default-registry!
(mr/composite-registry
(m/default-schemas)
(mu/schemas)
{:e.shopify/address1 [:map [:first_name string?]]
:e.shopify/address2 [:map [:city string?]]
:e.shopify/address-full [:merge
:e.shopify/address1
:e.shopify/address2]}))
(mg/generate :e.shopify/address-full)
;{:first_name "0GiD"
; :city "DMS5wc6mXcN4JCp9lJ"}
also, you could inject a mutable-registry
as last in the registry-chain and add the schemas using custom register!
fn. Mutate like a boss 馃檪
Oh this looks sweet! Thank you, mr Reiman!
Looking forward to this; I鈥檝e ended up fighting the tooling too often trying to get the compiler options working correctly in a consistent way.
Will malli support records?
[:and [:fn #(instance? RecordType %)]
[:map [:x :int] [:y :int]]]
Is a basic way if you just need validation and not generationi鈥檓 not clever enough to compose the :map
generator with map->RecordType
but i assume there is a way
I was thinking about something like schema is doing.
Cool. Looking forward to this.