Is there something in the current design that could prevent implementing that kind of schema salvaging? This is about altering some properties of an existing schema in a direct way:
{:int-vec [:vector :int]
:small-int-vec [:int-vec {:max 3}]}
I often have that kind of situation where I have a common schema (eg. :int-vec
) but once in a while I have to put more constraints in properties or slightly alter generation (eg. {:max 3}
).
Is there another obvious way, besides an external function that recreates the schemas with optional properties?(and besides directly using malli.util
)
Hi everybody, I am looking for the documentation of :ref, I always have a doubt if it is needed or not. I find :ref in the example of the documentation but no sentence explaining why it necessary or not.
@adam678 interesting idea. Should the latter fail if it would have children too? Or swap those too, if present?
@caumond :ref
is needed for recursion, no other utility I believe. It's implementation is lazy, so validators, explainers, generators etc. are realized only when needed.
I posted a PR yesterday
Doc PR welcome
@ikitommi I was thinking of altering properties only since this is both useful and not controversial. Altering properties doesn't change fundamental aspects of a schema (usually, I guess). If we could alter children, the following would look weird, almost evil:
{:int-vec [:vector :int]
:double-vec [:int-vec :double]}
😁 I got it !