Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to match distinct? predicate #32

Closed
blue0513 opened this issue Aug 12, 2020 · 1 comment
Closed

Fail to match distinct? predicate #32

blue0513 opened this issue Aug 12, 2020 · 1 comment

Comments

@blue0513
Copy link

Is there any way to define message for distinct? by phrase.

My simple example as follows.

;; (:require [clojure.spec.alpha :as s]
;;           [phrase.alpha :as p])

;; define s/def as `:distinct true`
(s/def ::distincted (s/coll-of integer? :distinct true))

;; s/explain-data return :pred as `distinct?`
(->> (::s/problems (s/explain-data ::distincted [1 1]))
     first
     :pred)
;; => distinct?

;; Use defphraser
(p/defphraser distinct? [_ _] "Should be distincted")

;; But phrase does not be invoked
(p/phrase-first {} ::distincted [1 1])
;; => nil

I expected p/phrase-first return Should be distincted but nil.
Any idea? Thanks!

@blue0513
Copy link
Author

Here we have a spec bug. Spec should use clojure.core/int? as predicted and not simply int?. They used to use simple symbols of press everywhere in the past. I thing they just forgot to add the namespace here.

I read #22 (comment) and https://clojure.atlassian.net/browse/CLJ-2168.
distinct? is also mentioned by others. I hope it will be fixed soon too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant