On Sun, Oct 16, 2016 at 11:40 PM, Ikuru Kanuma <[email protected]> wrote:
> Mauricio, thanks for the response!
> I agree that that gets what I asked for done, but that solution is in
> essence writing the same
> qualified/unqualified version of the spec twice and sounded redundant,
> which lead to my question.
> I guess it is what it is in that case...
>
Oh I see, maybe the reduncancy can be removed by creating a macro.
Something like:
(defmacro qualified-or-unqualified
[k & specs]
`(s/def ~k
(s/or :qualified (s/keys :req ~specs)
:unqualified (s/keys :req-un ~specs))))
And then defining the new specs would be something like:
(qualified-or-unqualified ::map-with-numbers ::some-number)
(s/valid? ::map-with-numbers {::some-number 3}) => true
(s/valid? ::map-with-numbers {:some-number 3}) => true
I'm sure the proposed macro is by no means complete, but I hope it points
you to one possible solution.
Cheers,
Mauricio
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.