0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 15:09:10 -05:00
penpot/frontend/uxbox/ui/form.cljs
2015-12-30 00:19:48 +02:00

22 lines
520 B
Clojure

(ns uxbox.ui.form
(:require [sablono.core :refer-macros [html]]
[uxbox.schema :as sc]))
(defn validate!
[local schema]
(if-let [errors (sc/validate schema @local)]
(swap! local assoc :errors errors)
(swap! local assoc :errors nil)))
(defn input-error
[local name]
(when-let [errors (get-in @local [:errors name])]
[:div.errors
[:ul {}
(for [error errors]
[:li error])]]))
(defn error-class
[local name]
(when (get-in @local [:errors name])
"invalid"))