4

As a result of creating a Schema coercer and then trying to coerce a set of data 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?

David Collie
  • 665
  • 2
  • 7
  • 21

1 Answers1

2

You can find the definition of the ValidationError type here (since you seem to be using Clojure on the JVM I deleted the #+cljs expressions):

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

And the definition for the ErrorContainer record here:

(defrecord ErrorContainer [error])

So to get more information about the error you could just access any of the fields of the inner 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
juan.facorro
  • 9,791
  • 2
  • 33
  • 41