From 2323e8f1c7ab470f83b1599c8c8440ce879256ca Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 24 Dec 2015 19:33:53 +0200 Subject: [PATCH] Add color validator. --- frontend/uxbox/schema.cljs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/uxbox/schema.cljs b/frontend/uxbox/schema.cljs index 5d1517e6d..bed73138d 100644 --- a/frontend/uxbox/schema.cljs +++ b/frontend/uxbox/schema.cljs @@ -18,10 +18,18 @@ (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"} + {:default-message-format "%s must be a uuid instance" + :optinal true} [v] (instance? cljs.core.UUID v)) +(v/defvalidator color + "Validates if a string is a valid color." + {:default-message-format "%s must be a valid hex color" + :optional true} + [v] + (not (nil? (re-find #"^#[0-9A-Fa-f]{6}$" v)))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Public Api ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;