'coerce-structure' should accept a spec as an argument, like 'coerce'
Frozenlock opened this issue · 3 comments
I'm just starting with spec, so I might be missing something,..
I think coerce-structure
should accept a spec as an argument in order to be able to handle unqualified maps.
(s/keys :req-un` [::first-name ::last-name])
{:first-name "Bob" :last-name "Smith"} ;; <---- can't be coerced
The issue here is that unqualified keywords are context-dependent. If you have a big enough structure you might have the same unqualified key representing different types of value. I guess this is a risk, but that doesn't mean we can't handle it.
The next feature that I want to implement is to send a replacement map so you can override coercions during the coerce-structure call, so I'm imagining we can translate from unqualified to qualified there as well, something like this:
(sc/coerce-structure {:first-name "Bob" :last-name "Smith"} {:first-name ::first-name :last-name ::last-name}
This would solve the issue for you?
That should do it.
Closed by ca513c2