-
Notifications
You must be signed in to change notification settings - Fork 93
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
Require data to match coll type #237
Comments
sounds like a bug. PR welcome. |
I wish I had enough Clojure / spec skills to submit a PR on this :-) |
While So it seems that one must be able to convert the value to its correct form for the spec check to succeed A call to |
@brjann there is some explanation in the mentioned PR above to fix the issue you reported. |
@wandersoncferreira wow, thanks! Does this also make |
Unfortunately not @brjann , it seems related but it is not the same error. From some investigation, seems like the code performing the destructuring of |
Which is interesting is that |
I would guess that ´[k v]´ is identified as a key value pair. |
Yes, I got the whole picture now. When the And the problem lies in the ;; the value of v
(let [x #{[1 2 3]}
[v & vs :as vseq] (seq x)]
v) ;; => [1 2 3]
;;; where v is used
(let [x #{[1 2 3]}
[v & vs :as vseq] (seq x)]
(conform* spec v)) And what is Now, I'm not sure how can we approach to fix the issue. I looked under the hood of EDIT: Seems like changing |
Thank you @wandersoncferreira ! |
It does not seem to be possible to require data to match the type of collection in a data spec.
For example both
(s/valid? (ds/spec ::x #{int?}) [1 2 3])
and(s/valid? (ds/spec ::x [int?]) #{1 2 3})
return true. I have been bitten by this where I accidentally passed a list instead of a set to a function, which passed the spec check and sincecontains?
accepts list, no error occured.Is it possible to require an exact match on collection type?
The text was updated successfully, but these errors were encountered: