As mentioned in the guide, while conformers can be used to implement 
coercions, that is something you should think about very carefully. When 
you register a spec with a conformer, you are making a choice for all 
possible future consumers of that spec as to how they are getting the 
conformed data back. That is a lot to "bake in" so tread very carefully, 
especially if you expect to share that spec with others.

On Wednesday, May 25, 2016 at 7:55:16 AM UTC-5, Gary Trakhman wrote:
>
> I answered my own question in the specific case, this seems to work:
>
> (defn to-int
>   [x]
>   (try
>     (Long/parseLong x)
>     (catch Exception _
>         nil)))
>
> (s/def ::intable (s/conformer to-int))
>
> (s/conform (s/cat :ints ::intable) ["5"])
> > {:ints 5}
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to