How to check ValidationError raised under Prismatic Schema enforcement?

As a result of creating the Schema coercium, and then attempting to force the dataset, I get as a result:

#schema.utils.ErrorContainer{:error #<ValidationError schema.utils.ValidationError@2abfe6ca>}

How do I get an explanation of what the actual validation error is?

+4
source share
1 answer

Here you can find the type definition ValidationError (since you seem to be using Clojure in the JVM, I removed #+cljs):

(deftype ValidationError [schema value expectation-delay fail-explanation])

And the definition for the ErrorContainerentry is here :

(defrecord ErrorContainer [error])

So, to get additional error information, you can simply access any of the internal fields ValidationError:

(defn validation-error-details [error]
  (let [values (juxt #(.schema %) 
                     #(.value %)
                     #(.expectation-delay %)
                     #(.fail-explanation %))]
    (->> error :error values)))

;; Usage
(validation-error-details error) ; where error holds the value you posted
+2
source

All Articles