Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Validations library for Clojure 1.2

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 src Added preconditions to predicates April 16, 2011
Octocat-spinner-32 test Added preconditions to predicates April 16, 2011
Octocat-spinner-32 .gitignore Initial commit October 23, 2010
Octocat-spinner-32 Added license information to README September 10, 2012
Octocat-spinner-32 project.clj Added date-time predicates using clj-time April 05, 2011


Valip is a validation library for Clojure. It is primarily designed to validate keyword-string maps, such as one might get from a HTML form.


Add the following dependency to your project.clj file:

[valip "0.2.0"]


The main validation function is valip.core/validate. It uses the following syntax:

(validate map-of-values
  [key1 predicate1 error1]
  [key2 predicate2 error2]
  [keyn predicaten errorn])

For each vector, the key is used to look up a value in the map. The map value is then tested with the predicate function. If the predicate fails, the error message is included in the map of errors returned by the validate function. A key may be tested multiple times with different predicates and errors.

If no predicate fails, nil is returned. If at least one predicate fails, a map of keys to errors is returned:

{key1 [error1]
 key2 [error2]
 keyn [errorn]}

The errors are listed in a vector, because there may be multiple errors for the same key.

For example:

(use 'valip.core 'valip.predicates)

(def user
  {:name "Alice", :age 7})

(validate user
  [:name present? "must be present"]
  [:age present? "must be present"]
  [:age (over 18) "must be over 18"])

=> {:age ["must be over 18"])


Valip has a number of useful predicates and functions that generate predicates. More of these useful predicates will be added as the library matures.

You can find these predicates in the valip.predicates namespace.


Copyright © 2012 James Reeves

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.