Fork me on GitHub
#malli
<
2021-03-24
>
respatialized13:03:37

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).

nilern13:03:44

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?)

nilern13:03:19

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

respatialized13:03:44

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.

nilern13:03:09

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

nilern13:03:14

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

respatialized14:03:25

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.

nilern14:03:50

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