This commit is contained in:
Andrey Antukh 2015-12-14 20:31:21 +02:00
parent 56f7613453
commit 6b6aba7358
8 changed files with 258 additions and 37 deletions

View file

@ -1,5 +1,5 @@
(ns uxbox.schema
(:refer-clojure :exclude [keyword?])
(:refer-clojure :exclude [keyword uuid])
(:require [bouncer.core :as b]
[bouncer.validators :as v]))
@ -7,13 +7,21 @@
;; Validators
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(v/defvalidator keyword?
(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))
(v/defvalidator uuid
"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 uuid instance"}
[v]
(instance? cljs.core.UUID v))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public Api
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;