practicalli / practicalli/clojure
Aliases in clojure.spec
Nobody has claimed this yet.
- Dominant language
- Makefile
- Stars
- 117
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
Is there a way to use spec on a map without mandating that the kw and spec have the same name? Like
{:sponsor value-conforming-to-:person-spec}
If you're working with unqualified keys, probably the simplest workaround would be an alias spec:
(s/def ::person-spec ,,, whatever ,,,)
(s/def :person/sponsor ::person-spec)
(s/def ::sponsor-map (s/keys :req-un [:person/sponsor ,,,]))
That key will be :sponsor but the spec will be :person/sponsor which is aliased to ::person-spec.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's Clojure spec examples, especially s/def, s/keys, and the proposed alias between ::person-spec and :person/sponsor. Clarify whether this pattern is supported and document the recommended way to use a differently named spec with a map key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100