From 5165ac6e528986a3cd3eeb6d778d16592cc7f936 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 20 Nov 2016 21:21:02 +0100 Subject: [PATCH] Add `valid?` predicate that prints debug info to stdout. When the predicate fails. Very usefull when used with preconditions that by default does not print nothing. --- backend/src/uxbox/util/spec.clj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/uxbox/util/spec.clj b/backend/src/uxbox/util/spec.clj index 5acecd424..311f73db9 100644 --- a/backend/src/uxbox/util/spec.clj +++ b/backend/src/uxbox/util/spec.clj @@ -31,6 +31,12 @@ :context (s/explain-data spec data)) result))) +(defn valid? + [spec data] + (if (s/valid? spec data) + true + (s/explain spec data))) + ;; --- Predicates (defn email?