Fork me on GitHub
#malli
<
2023-08-17
>
David G00:08:54

Is there a particular reason why there's map-of but the vector equivalent is vector in the schemas?

ikitommi08:08:35

no good reason. (bad) names could be revisited if there will be 1.0.0 to clean up things.

ikitommi08:08:42

good thing is that you can always already add these to the registry:

:vector-of (-collection-schema {:type :vector-of, :pred vector?, :empty []})
:set-of    (-collection-schema {:type :set-of, :pred set?, :empty #{}, :in (fn [_ x] x)})
...

🔥 2
respatialized16:08:06

Given a value v and a schema registry with a bunch of named schemas, is there a way to efficiently get all the schemas that v conforms to?

ikitommi08:08:54

efficiently - you should loop the registry and create a map of name -> m/validator of it. Validators are pure functions and can be cached.

ikitommi09:08:38

maybe therw could be a helper for this in malli.util?

respatialized00:08:27

Yes, it looks like much more fully realized version of what I once called "https://fabricate.site/background/finite-schema-machines" - thanks for the link!

👍 4