bouncer is a validation DSL for Clojure apps
Github: https://github.com/leonardoborges/bouncer
Clojars: https://clojars.org/bouncer
TL;DR; of version 0.3.1-beta1:
You can now customise error messages however you like:
(def person {:name "Leo" :age "NaN"})
(defn custom-message-fn [{:keys [path value metadata]}]
(format "'%s' in field %s should be a %s" value path (:validator
metadata)))
(b/validate custom-message-fn
person
:name v/required
:age v/number)
;; [{:age ("'NaN' in field [:age] should be a :bouncer.validators/number")}
;; {:age "NaN",
;; :name "Leo",
;; :bouncer.core/errors
;; {:age
;; ("NaN in field [:age] should be a :bouncer.validators/number")}}]
To learn more about this new feature please have a look at the section
"Internationalization and advanced error messages"* in the
README<https://github.com/leonardoborges/bouncer/blob/master/README.md#internationalization-and-advanced-error-messages>
.
Hats off to Vadim Platonov (https://github.com/dm3) for this pull request.
This feature is backwards compatible so existing code will be unaffected.
A
CHANGELOG<https://github.com/leonardoborges/bouncer/blob/master/CHANGELOG.md>is
also available.
Feedback welcome.
Cheers,
Leonardo Borges
www.leonardoborges.com
--
--
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/groups/opt_out.