explain-data problems don't provide resolved symbols under :pred

Description

Currently, explain-data returns unresolved preds. This is a problem when trying to write a custom explain print function that chooses what to do based on the predicate as it does not have enough information.

(require '[clojure.spec :as s]) (defn password-valid-length? [pass]   (> (count pass) 12)) (s/def ::password (s/and string? password-valid-length?)) (-> (s/explain-data ::password "foobar") ::s/problems first :pred) ;;=> password-valid-length? ;;expected: user/password-valid-length?

Cause: Currently, explain* returns preds in the abbrev form for all spec impls.

Proposed: Have explain* return resolved preds. In cases where the abbreviated form should be used (anything for human consumption at either the repl or an error message), convert to it. For example, explain-printer should (and already does) do this.

Patch: clj-2059-2.patch

  • Changes all spec impls to avoid calling abbrev on preds when building explain-data

  • Undoes op-describe change for s/? in CLJ-2042 and fixes this at a higher level by calling res on the incoming pred (this is a better fix)

  • Changes the expected test output for spec tests to expect the resolved pred

Environment

None

Attachments

2
  • 10 May 2017, 06:46 PM
  • 15 Nov 2016, 08:01 PM

Activity

Show:

Alex MillerMay 10, 2017 at 6:46 PM

Updated patch to apply to spec.alpha

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code and Test

Priority

Affects versions

Fix versions

Created November 15, 2016 at 7:08 PM
Updated May 26, 2017 at 3:39 PM
Resolved May 26, 2017 at 3:39 PM