-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add integrant.spec namespace #38
Conversation
This namespace aims to provide utilities for clojure.spec, specially regarding validation of configuration maps. Notably : - `integrant.spec/ref` creates specs for refs. - :integrant.spec/configuration validates a configuration map by finding the spec for every key in the global registry. It takes into account derived and composite keys. Also, it checks for ambiguous refs.
I think I'd still prefer The functions that do one thing can be replaced with anonymous functions, or with higher level functions (e.g. You also might have a problem with your editor, because all the new lines are doubled up. |
I actually use a lot of space which looks very clear in my editor but totally weird on github. I like to formalize private fns that do only one thing. But those are a matter of style and will be modified to match more closely 'integrant.core' if you approve the code, so at least there would be coherence. For the time being, I suggest you to focus on how ::ig.spec/configuration behaves and if you like it, we can discuss how to present it. As far as I'm concerned, it does the job. I will incorporate this to my current projects this week to get a better feedback. |
I'd rather a The |
Agreed on Regarding |
Regarding So perhaps something like: (s/unambiguous-refs? config)
(s/no-missing-refs? config)
(s/derived-keys & {:keys [req opt]})
(s/ref key)
(s/refset key)
(s/config & opts) |
Sorry for the (very) long delay, I was super busy with work. I did not follow what happened with integrant meanwhile but it looks like this PR might still be of interest. Did you have requests for that kind of things ? |
I haven't received any more requests for compatibility with spec. I think it would be nice to have, but somewhat complex to implement, so it hasn't been a priority of mine. |
Well if nobody is clearly interested in that, I will leave it as it is for the time being. Yes, I admit it is less straightforward to implement than I first thought. |
Sorry for the delay ! This pull request is related to issue #32 for adding the 'integrant.spec' namespace. My solution is slightly different, the ::ig.spec/configuration spec replaces your idea of
ig.spec/derived-keys
as there is no need for a function, but the goal is the same. In order to work well enough withs/explain
, I useds/multi-spec
in a bit of an unconventional way. If you like it, I can write tests. For the time being, let's say it's "repl proven".This namespace aims to provide utilities for clojure.spec, specially
regarding validation of configuration maps.
Notably :
integrant.spec/ref
creates specs for refs.finding the spec for every key in the global registry. It takes into
account derived and composite keys. Also, it checks for ambiguous
refs.