malli

https://github.com/metosin/malli :malli:
Panel 3000 2021-03-24T01:56:09.215400Z

It does work if the registry is passed in the options map

(mu/optional-keys
 [:map
  [:time :inst]
  [:id :uuid]]
 {:registry
  (mr/composite-registry
   m/default-registry
   {:inst (m/-simple-schema
           {:type :inst
            :pred inst?})})})

respatialized 2021-03-24T13:16:37.218400Z

Is there a preferred way to ensure that a seqex schema is a given collection type? right now I can use [:and vector? [:catn [:bool :boolean] [:int :int]]], but I was wondering if there was a more canonical or performant way of doing it (generators often fail to satisfy the predicate, for example).

nilern 2021-03-24T13:23:44.220500Z

No. I think it only matters for generators and :and is in general not generator-friendly (currently the generator is a gen/such-that, which is pretty bad but how much better can we even get?)

nilern 2021-03-24T13:25:19.221900Z

(For that particular example I would probably use [:tuple :boolean :int] but you might really have something that actually needs seqex)

respatialized 2021-03-24T13:29:44.224100Z

yeah, that was a deliberately simplified example (the actual motivating use case is validation on hiccup forms). I think I'll need to take a crack at custom generators for this use case.

nilern 2021-03-24T13:33:09.225100Z

I think I've seen some discussion of this previously and it should be simple to add. So maybe file an issue as well?

nilern 2021-03-24T13:51:14.226300Z

It is unfortunate that we have to add non-orthogonal props like [:string {:min 5}] and now maybe [:catn {:type :vector}] to get decent generators

respatialized 2021-03-24T14:04:25.228Z

minimallist has an additional https://github.com/green-coder/minimallist/blob/f10ebbd3c2b93e7579295618a7ed1e870c489bc4/src/minimallist/helper.cljc#L72 that does this, minimallist.helper/in-vector, but it chooses a map-based representation for schemas that allows additional metadata of :coll-type to be assoc'd to the schema. Unclear how something similar would work in malli.

nilern 2021-03-24T14:08:50.229100Z

It would just add that to props but the seqex schemas still have to be updated to use that information