This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-10
Channels
- # announcements (4)
- # asami (36)
- # babashka (11)
- # beginners (31)
- # calva (71)
- # clojure (51)
- # clojure-boston (2)
- # clojure-europe (3)
- # clojure-nlp (4)
- # clojuredesign-podcast (1)
- # clojurescript (30)
- # community-development (25)
- # css (1)
- # cursive (10)
- # datomic (1)
- # events (1)
- # figwheel-main (1)
- # girouette (5)
- # graalvm (18)
- # graphql (1)
- # honeysql (37)
- # instaparse (3)
- # jobs (1)
- # malli (6)
- # polylith (2)
- # releases (3)
- # remote-jobs (5)
- # rum (1)
- # shadow-cljs (16)
- # sql (1)
- # tools-deps (37)
- # vscode (11)
Some breaking changes coming to the extender-api, moving -type
and -type-properties
from Schema
to IntoSchema
. And some new methods so that we can describe the Malli schemas with Malli:
(defprotocol IntoSchema
(-type [this] "returns type of the schema")
(-type-properties [this] "returns schema type properties")
(-properties-schema [this] "maybe returns :map schema describing schema properties")
(-children-schema [this] "maybe returns sequence schema describing schema children")
(-into-schema [this properties children options] "creates a new schema instance"))
also, much better print presentations now:
(m/-enum-schema)
; => #IntoSchema{:type :enum}
(m/schema [*1 "A" "B"])
; => [:enum "A" "B"]
(type *1)
; => :malli.core/schema
If I want to generate valid malli schemas of the form: [:map [:key1 int?] [:key2 int?] .... [:keyn int?]] using another malli schema - a meta-schema so to speak - what would that meta-schema look like? I've tried: [:tuple [:= :map] [:+ [:tuple simple-keyword? [:= :int]]]]) But it has a flaw: it e.g. generates: [:map [[:key1 int?] [:key2 int?] .... [:keyn int?]]] one pair of square brackets too much around the key-value-tuples. Does anybody know how to solve this using malli?
@roseneck it’s a sequence:
(mg/generate
[:cat {:gen/fmap vec}
[:= :map]
[:* [:tuple :keyword :int]]]
{:size 42, :seed 200})
;[:map
; [:IjPg2 -5908]
; [:E+:H9l* 287044292]
; [:*vCe._5z 10637946460]
; [:kLq67 -125]
; [:J9?D+FY4G 718]
; [:*_1*Rc+A -908]
; [:?qi 1523]
; [:x.+ -1]
; [:D4*5 -13]
; [:.C4 -80]
; [:r-A 3161894]
; [:rcC 1118]
; [:Q*._k*w8iG 194253522]
; [:o!dfA 21159377159]
; [:nx!h 973119]
; [:C:!Rw 109221]
; [:?N38.*3? -11854145]
; [:lb5Z?9V?_v* -42]
; [:i!M.l?D+ 2026049]
; [:++k43x -141680]
; [:U- -8]
; [:*x 1491554935632]
; [:heX2 1957851783]
; [:_PZ?q3+! -83]
; [:*H*x8N:.! 1452]
; [:k_Oy2+LXD -864224065]
; [:p 55]
; [:*o+1ul*5?? -1766412]
; [:W7:-61 -17174129950]
; [:qv79TTj_+ 21380662]
; [:h -30089]]
Thanks a lot! 🙂