Fork me on GitHub

looking forward for that. I鈥檓 watching the guardrails repo, but think that鈥檚 going to be much more.


> (extensible, but starting with Clojure spec)

awesome 3

Yeah, but will be a commercial product, so hard to contribute and see what's going on probably


Looking forward to the new function schema - just saw the tweet!

馃憤 3

@emccue Malli is a dynamic schema/type system, it鈥檚 not a static type system. tools like clj-kondo and typed clojure can do static analysis, maybe copilot too? Would love to see tooling get better and happy to help, but no time or skills to do anything non-trivial except to integrate into existing tooling. My point was that resolving fn arity using generative testing or 3rd party tools (clj-kondo) is a hard way to do something that would be easy to do in the core language itself. With core clojure: does a ring middleware chain would work for an async (3) arity? run and see if it throws arityexception 馃槥


I鈥檓 hope and think we鈥檒l see great new developer tooling for clojure in 2021, from the community.

馃 3

added more benchmarks to repo, parsing vs spec:

;; 44碌s
(let [spec (s/* (s/cat :prop string?,
                       :val (s/alt :s string?
                                   :b boolean?)))
      parse (partial s/conform spec)]
    (parse ["-server" "foo" "-verbose" "-verbose" "-user" "joe"])))

;; 2.5碌s
(let [schema [:* [:cat*
                  [:prop string?]
                  [:val [:alt*
                         [:s string?]
                         [:b boolean?]]]]]
      parse (m/parser schema)]
    (parse ["-server" "foo" "-verbose" "-verbose" "-user" "joe"])))

Jakub Zika16:02:13

Hi guys, I am trying to generate some random date with (mg/generate inst?) but i am not sure how :seed or :size works here. I am getting 1969 or 1970 in 99% cases. How to get a date like any >1980? Thanka dwh-replicator.database> (mg/generate inst? {:seed 20}) ;; => #inst "1970-01-01T00:00:00.000-00:00" dwh-replicator.database> (mg/generate inst? {:seed 42}) ;; => #inst "1970-01-01T00:00:00.000-00:00"


@jakub.zika-extern there's a good talk that explains how :seed and :size interact when writing custom generators. It even mentions the datetime problem @ 31:54. 1. The proposed solution in the talk is a custom generator that splits the datetime into separate domain bits (year / month / day / etc.) 2. A different solution (as seen e.g. is to change the way you choose an initial seed integer (that is used to coerce to date).

Jakub Zika21:02:17

I am mapping DB types to clojure types, so varchar(255) goes to [string? {:min 0 :max 255}] etc. I am using these derived schemas to: 1. validate data : (malli/validate [string?] "hoy") 2. generate sample data : (malli.generator/generate [string?]) When I will go for custom generators then I will have to create new validators, correct?


You'll need to pass in the custom generator to the spec (not necessarily when validating, but at the very least wen generating sample data).

馃憤 3

so instead of

[string? {:min 0 :max 255}]
you'll have to wrap it, eg:
[:and {:gen/elements ["kikka" "kukka" "kakka"]} [string? {:min 0 :max 255}]]


where you use one of :gen/elements, :gen/gen, :gen/fmap, etc.


^ I think you might even be able to just change the default :gen/gen of the specific type by modifying the malli registry globally (but then you're changing it for everything... which has its own issues ;))


OR, perhaps make a custom registry where you override the :gen/gen for the basic types you're interested in (e.g. instant); and then pass in the custom registry only when generating sample data


no need to wrap into :and, this works too: [:string {:min 0, :max 100, :gen/min 10, :gen/max 20, :gen/fmap (partial * 2)}]

馃憤 3

the default schema generators are implemented as multimethods, so for global effects, one can just re-mount generator fof 'inst? for example. not recommended.

Alex Whitt18:02:22

Would anyone like to jump on this discussion thread I created on the subreddit? (I'd prefer to keep it there so it doesn't disappear behind Slack's paywall)

馃敟 9