Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'coerce-structure' should accept a spec as an argument, like 'coerce' #3

Closed
Frozenlock opened this issue Jul 27, 2017 · 3 comments
Closed

Comments

@Frozenlock
Copy link

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
@wilkerlucio
Copy link
Owner

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?

@Frozenlock
Copy link
Author

That should do it.

@wilkerlucio
Copy link
Owner

Closed by ca513c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants