Welcome! Please see the About page for a little more info on how this works.

0 votes
in Spec by

When using spec/or without parameters spec/valid? and spec/explain are resulting in a contradiction.

Minimal example:

(s/valid? (s/or) :something) => false (s/explain (s/or) :something) Success! => nil

Similar to {{or}}, {{s/or}} should fail to validate anything (so first call is good) but should report an error with explain (so explain result is bad).

Proposed: In the s/or explain, the logic maps over all preds to build a problem list about each value not matching, but the base case of no preds isn't explicitly handled. The change in the code checks for that case and builds a specific explain problem error for the overall s/or not matching. Patch includes fix and tests for (s/or) and (s/and) (which is ok).

Patch: clj-2360.patch

1 Answer

0 votes
Reference: https://clojure.atlassian.net/browse/CLJ-2360 (reported by alex+import)