Validating data happens so often, it's good to have a DSL to express the validation rules our data has to pass. This makes the rules easier to create, understand, and maintain.
Valip (https://github.com/weavejester/valip) provides this. It's aimed at validating input from web forms, so it expects to validate maps with string values. We'll need to work around that expectation a time or two, but it isn't difficult.
We need to make sure the Valip library is in our Leiningen project.clj
file. This can be done using the following code snippet:
:dependencies [[org.clojure/clojure "1.4.0"]
[valip "0.2.0"]]
And, we need to load it into our script or REPL. This can be done using the following code snippet:
(use 'valip.core 'valip.predicates)