Clojure

[spec] Inconsistent results from s/valid? and s/explain when using s/or without parameters

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: Release 1.11
  • Component/s: None
  • Labels:
  • Environment:
    org.clojure/spec.alpha "0.1.143"
  • Patch:
    Code and Test
  • Approval:
    Vetted

Description

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

Activity

There are no comments yet on this issue.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated: