Thanks Colin, Thanks Erik Exactly what I was looking for. I've updated the gist with Colin's suggestion and a bit of destructuring. If this project gets any bigger I will definitely look at vlad <https://github.com/logaan/vlad> and Prismatic Schema <https://github.com/Prismatic/schema>.
BDF. On Thu, Nov 12, 2015 at 12:02 PM, Erik Assum <e...@assum.net> wrote: > There is also https://github.com/logaan/vlad which helps with validation. > > Erik. > -- > i farta > > Den 12. nov. 2015 kl. 17.12 skrev Colin Yates <colin.ya...@gmail.com>: > > A nicer equivalent form would be: > > (cond-> [] > this-error? (conj “It failed with this error”) > that-error? (conj “It failed with that error”)) > > However, purely for validation there are a few utilities out there > already. Checkout the ‘Validation’ section on > http://www.clojure-toolbox.com > > Also, in terms of enforcing contracts - Prismatic Schema is highly > recommended but hard to ‘englishify’ the errors. Failures are considered > API failures rather than happy-case failures. > > On 12 Nov 2015, at 16:09, Brian Forester <brian.fores...@gmail.com> wrote: > > I'm writing a very small REST application in clojure using compojure and > ring. One problem is that I don't have anyone who can review my work or > provide feedback. > > > I've written a small function to validate a simple JSON request. I'm > validating the three values that are in the post and collecting the errors > for return. > > The core mechanic I've used > > (swap! errors str "'grepString' must not be null or empty.\n")) > > does not seem to be a very idiomatic clojure way to solve this simple problem. > > > https://gist.github.com/BDF/8e61daf8fe8b602a248a > > > Any feedback is appreciated. > > BDF. > > > > > -- > 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. > > > -- > 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. > > -- > 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. > -- 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.