The ClojureWerkz Blog

News and updates about ClojureWerkz projects

Validateur 1.5.0 Is Released

TL;DR

Validateur is a functional validations library inspired by Ruby’s ActiveModel. Validateur 1.5 introduces ways to customize error messages.

Changes between Validateur 1.4.0 and 1.5.0

Optional messages in built-in validators

All built-in validators but length-of accept optional messages for all cases. Their formatting is fixed and based in default ones. For example:

1
2
3
((inclusion-of :genre :in #{"trance", "dnb"} :message "debe pertenecer a:")
 {:genre "pasodoble"})
;; [false {:genre #{"debe pertenecer a: trance, dnb"}}]

Optional function callback to parametrize the construction of messages

All built-in validators accept an optional function callback which will be called by the validator to build the returned error message. The main goal is to facilitate the inclusion of i18n in messages (like previous one but in a more flexible way). For example:

1
2
3
4
5
((inclusion-of :genre :in #{"trance", "dnb"}
               :message-fn (fn [validator map prop & args]
                              [validator map prop args]))
 {:genre "pasodoble"})
;; [false {:genre #{[:inclusion {:genre "pasodoble"} :genre (#{"trance" "dnb"})]}}]

Change Log

We recommend all users to upgrade to 1.5.0.

Validateur change log is available on GitHub.

Thank You, Contributors

Javier Neira contributed key features in this release.

Validateur is a ClojureWerkz Project

Validateur is part of the group of libraries known as ClojureWerkz, together with

  • Langohr, a Clojure client for RabbitMQ that embraces the AMQP 0.9.1 model
  • Monger, a Clojure MongoDB client for a more civilized age
  • Elastisch, a minimalistic Clojure client for ElasticSearch
  • Cassaforte, a Clojure Cassandra client built around CQL
  • Neocons, a client for the Neo4J REST API
  • Welle, a Riak client with batteries included
  • Quartzite, a powerful scheduling library

and several others. If you like Validateur, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

Michael on behalf of the ClojureWerkz Team