Fork me on GitHub
#malli
<
2021-05-13
>
Adam Helins07:05:19

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?

Adam Helins07:05:18

(and besides directly using malli.util)

caumond11:05:58

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.

ikitommi12:05:25

@adam678 interesting idea. Should the latter fail if it would have children too? Or swap those too, if present?

ikitommi12:05:28

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

ikitommi12:05:40

Doc PR welcome

caumond12:05:46

😁 I got it !

caumond20:05:48

I posted a PR yesterday

Adam Helins12:05:10

@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]}