This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-30
Channels
- # admin-announcements (1)
- # adventofcode (2)
- # announcements (2)
- # babashka (60)
- # beginners (48)
- # cherry (1)
- # cider (16)
- # clj-kondo (4)
- # clojure (53)
- # clojure-belgium (3)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-poland (4)
- # clojure-uk (6)
- # clojuredesign-podcast (19)
- # clojurescript (39)
- # community-development (12)
- # cursive (4)
- # datalevin (7)
- # datomic (23)
- # honeysql (14)
- # hyperfiddle (3)
- # instaparse (3)
- # lsp (3)
- # malli (10)
- # off-topic (34)
- # overtone (8)
- # polylith (2)
- # re-frame (9)
- # reitit (3)
- # releases (1)
- # squint (16)
- # timbre (7)
- # wasm (2)
- # xtdb (8)
I was reading through the malli docs, and tried the following:
user=> (require '[malli.provider :as mp] '[malli.transform :as mt])
nil
user=> (mp/provide
#_=> [{:id "caa71a26-5fe1-11ec-bf63-0242ac130002"
#_=> :time "2021-01-01T00:00:00Z"}
#_=> {:id "8aadbf5e-5fe3-11ec-bf63-0242ac130002"
#_=> :time "2022-01-01T00:00:00Z"}]
#_=> {::mp/value-decoders {'string? {:uuid mt/-string->uuid
#_=> 'inst? mt/-string->date}}})
[:map [:id :string] [:time :string]]
but was expecting:
; => [:map [:id :uuid] [:time inst?]
is there another example of using malli.provider/value-decoders
or did the conventions for using it change? I'm on 0.13.0hi. the docs are not up-to-date, could you PR a fix here? what has changed:
• provider creates real schemas instead of predicates, e.g. :string
over string?
• this applies to the ::mp/value-decoders
so, this is the new correct:
(mp/provide
[{:id "caa71a26-5fe1-11ec-bf63-0242ac130002"
:time "2021-01-01T00:00:00Z"}
{:id "8aadbf5e-5fe3-11ec-bf63-0242ac130002"
:time "2022-01-01T00:00:00Z"}]
{::mp/value-decoders {:string {:uuid mt/-string->uuid
'inst? mt/-string->date}}})
; => [:map [:id :uuid] [:time inst?]]
thank you for your help! I'll make a PR.
I’m getting an OutOfMemoryError
when calling malli.core/validate
... where the return type is a Malli SchemaObject.
Both of these calls with the below input. I did notice someone asking a https://clojurians.slack.com/archives/CLDK6MFMK/p1617265988295000?thread_ts=1617177945.267200&cid=CLDK6MFMK. But there doesn’t seem to be a resolution.
Is there something else I need to know about fn validation?
(m/explain =>fn-schema my-fn)
(m/validate =>fn-schema my-fn {:gen/max 1})
(def SchemaMap
[:map
[:foo/a string?]
[:foo/b inst?]])
(def SchemaObject
(m/schema
[:schema {:registry custom-registry}
::thing]
{:registry default-registry}))
;; Works
(def =>fn-schema
(m/schema
[:=> [:cat SchemaObject string? inst?] string?]
{::m/function-checker mg/function-checker}))
;; Fails
(def =>fn-schema
(m/schema
[:=> [:cat SchemaObject string? inst?] SchemaMap]
{::m/function-checker mg/function-checker}))
;; hangs until surfacing... Execution error (OutOfMemoryError) at clojure.test.check.generators/gen-tuple$fn (generators.cljc:89).
is ::thing
a recursive schema?
https://github.com/metosin/malli/tree/master#recursive-schemas
> Without the :ref
keyword, malli eagerly expands the schema until a stack overflow error is thrown:
@U051V5LLP Thanks for replying.
::thing
is a nested map, where some of the leaves reference other entries in the custom-registry
.
I combed through custom-registry
and I don’t see anything pointing back to ::thing
. Ie no circular references. But is there a tool or flag that might detect that?
I got excited when I saw malli.provider
because I loved F# type providers, and I'm always struggling to give other readers of code concrete examples of data. It's not really a technical question I was just wondering if anybody had done anything with malli.provider
that they felt particularly proud of or thought clever to share. Looking to grok whats out there
working with a ~8 year old datomic database which doesn't have great docs of the shape of entities. Picked a few db.unique identity attributes and queried for a large sample of them using (pull [*])
to get all first-level attributes on those entities and then pass the result to malli.provider - very useful
Similar thing, but off a Cassandra data store. I used a bunch of query results to start off my specs.