WIP: project creation now work.

This commit is contained in:
Andrey Antukh 2015-12-14 14:17:18 +02:00
parent 62b9267d4f
commit 56f7613453
11 changed files with 201 additions and 103 deletions

View file

@ -0,0 +1,30 @@
(ns uxbox.schema
(:refer-clojure :exclude [keyword?])
(:require [bouncer.core :as b]
[bouncer.validators :as v]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Validators
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(v/defvalidator keyword?
"Validates maybe-an-int is a valid integer.
For use with validation functions such as `validate` or `valid?`"
{:default-message-format "%s must be a keyword"}
[v]
(cljs.core/keyword? v))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public Api
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn validate
([schema] #(validate schema %))
([schema data] (first (b/validate data schema))))
(defn validate!
([schema] #(validate! schema %))
([schema data]
(when-let [errors (validate schema data)]
(throw (ex-info "Invalid data" errors)))))