Fork me on GitHub

will malli eventually do, for lack of a better term, a keyset coerce/conform? I try to use open keysets as much as possible, but always struggle the best way to handle stuff like the following

(-> {:a .. b:.. :c .. :d} ; say input from api call
     validate ; we only care about :a,:b and :c but ignore :d
     do-something-with-a-and-b ; fine with a s/keys [:a :b] or m/validate equivalent precondition
     do-something-with-c ; fine with a s/keys [:c]
     (select-keys [:a ::c]) ; or (transform my-schema)
     (write-a-b-c-to-datomic) ; at this point I want a closed schema/spec precond, that could potentially narrow the keys on the way in? 


@eoliphant would something like (mu/select-keys map-of-abc [:a :b]) be good? you can always make maps closed, to either fail on extra keys or to strip extra keys in transform


e.g. select-keys, but for schemas


hmm yeah, perhaps strip extra on transform is the way to go? again, just been thinking about this, in terms of a structural coercion, but that might not be the best approach


I think it's the way to go: open schemas are great , but external systems like db's aren't always happy with extra stuff in. We are at least stripping data away at the boundaries.


there is malli.transform/strip-extra-keys-transformerfor this


especially for stuff like datomic lets you do maps, etc all the way down, but it gets understandably upset if you pass in attributes it doesn’t know about 😉