Validateur 2.2.0 is released
TL;DR
Validateur is a functional validations library inspired by Ruby’s ActiveModel. Validateur 2.2 is a minor feature release.
Changes Between 2.1.0 and 2.2.0
nested
nested
is a new validator runner for nested attributes.
(require '[validateur.validation :refer :all])
(let [v (vr/nested :user (vr/validation-set
(vr/presence-of :name)
(vr/presence-of :age)))
extra-nested (vr/nested [:user :profile]
(vr/validation-set
(vr/presence-of :age)
(vr/presence-of [:birthday :year])))]
(v {})
;= {[:user :age] #{"can't be blank"}
[:user :name] #{"can't be blank"}}
(v {:user {:name "name"}})
;= {[:user :age] #{"can't be blank"}}
(extra-nested {:user {:profile {:age 10
:birthday {:year 2004}}}})
;= {}
(extra-nested {:user {:profile {:age 10}}})
;= {[:user :profile :birthday :year] #{"can't be blank"}}
Contributed by Sam Ritchie.
validate-by
validate-by
is a new validator function. It returns a function that,
when given a map, will validate that the + value of the attribute in
that map is one of the given:
(require '[validateur.validation :refer :all])
(validation-set
(presence-of :name)
(presence-of :age)
(validate-by [:user :name] not-empty :message \"Username can't be empty!\"))
Contributed by Sam Ritchie.
Full Change Log
Validateur change log is available on GitHub.
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.
About The Author
Michael on behalf of the ClojureWerkz Team