Skip to content
Myles Megyesi edited this page Oct 6, 2012 · 3 revisions

Usage

(defvalidator location-validator
  [:gps :with {:message "bad gps!" :validator (fn [attrs] (not (or (nil? (:latitude attrs)) (nil? (:longitude attrs)))))}])

(location-validator {:latitude "" :longitude nil})
; {:gps ["bad gps!"]}

(location-validator {:latitude "90" :longitude "20"})
; {}

Options:

  • :validator The validator to run against the record. This function should accept a map and return a boolean. Default nil.

Default error message:

"is invalid"

Clone this wiki locally