Question around verification on the ValidationError

10 views
Skip to first unread message

Yang Yang

unread,
Jan 28, 2017, 6:01:43 AM1/28/17
to Plumbing and Graph: the Clojure utility belt
Hi all,
I am writing some integration type test for all validation. For happy pass case, it's easy just assert the data is exactly the same. But for the negative case, since I am interested in the validation result/information, I am using this function validation-error-explain https://github.com/plumatic/schema/blob/master/src/cljx/schema/utils.cljx#L91 in my test to get a list and verify the information is what I expected.

(validation-error-explain (first (keys (:error (#'sut/is-valid-root-elements? (merge MIN_VALID_DATA {:exteral-key "bla"}))))))
;; => (not ("Resource must starts with /" :exteral-key))


Is this the correct way to verify the validation result? is there a better way? Thanks.

Jason Wolfe

unread,
Jan 28, 2017, 12:57:56 PM1/28/17
to Yang Yang, Plumbing and Graph: the Clojure utility belt
The ValidationError will not necessarily be at the top level.  The easiest thing would be to just call e.g. `pr-str` on the error (or at least, that's what we do in the schema tests). 


-Jason

--
You received this message because you are subscribed to the Google Groups "Plumbing and Graph: the Clojure utility belt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prismatic-plumbing+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages