Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
validateur nesting
(defn validate-under [attr validator]
(fn [m]
(let [result (validator (get m attr))]
[(empty? result) (v/nest attr result)])))
(def example-v
(validate-under :foo (v/validation-set (v/presence-of :bar)))))
(example-v {:foo {:bar 1}})
;= {}
(example-v {:foo {}})
;= {[:foo :bar] #{"can't be blank"}}
(example-v {})
;= {[:foo :bar] #{"can't be blank"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.