You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking the code I saw that in the encode function there is an conform + unform pair, but the data
being passed to the unform is {:error "error" :status "some-other-error"}, therefore the multi-spec fails to perform the dispatch and find the right spec to do the unform.
Possible solution?
In the issue #119, you guys mention the possibility of:
if there is a way to ask from a multi-spec what spec it will dispatch for this given data, we could unform against that spec
directly, not for the multispec itself.
Which I imagine maps to these lines of code in the spec source-code (ref1 and ref2), wheremm is the multi-method.
(let [predx #(let [^clojure.lang.MultiFn mm @mmvar]
(c/and (.getMethod mm ((.dispatchFn mm) %))
(mm %)))]
; ....
(unform* [_ x] (if-let [pred (predx x)]
(unform pred x)
(throw (IllegalStateException. (str"No method of: " form " for dispatch value: " (dval x))))))
I believe it would be possible to modify the encode to get the right spec to use in the unform in the case of multi-spec.
But I'm not sure if this would be the right place to do so and how it would impact when we merge multi-spec with others specs. Maybe it would be better to wrap the multi-spec in a st/spec and modify the unform* there, but probably it would need access to the original data.
What do you think? Would be ok to add this as a condition in the encode function?
If you guys could give me direction on the best way to proceed, I could try to submit a patch.
Thanks!
The text was updated successfully, but these errors were encountered:
Hello!
Problem
Version: 0.10.2
The following code fails:
with the following exception:
I believe this relates to #119 .
Looking the code I saw that in the encode function there is an
conform
+unform
pair, but the databeing passed to the
unform
is{:error "error" :status "some-other-error"}
, therefore the multi-spec fails to perform the dispatch and find the right spec to do theunform
.Possible solution?
In the issue #119, you guys mention the possibility of:
Which I imagine maps to these lines of code in the spec source-code (ref1 and ref2), where
mm
is the multi-method.I believe it would be possible to modify the encode to get the right spec to use in the
unform
in the case of multi-spec.But I'm not sure if this would be the right place to do so and how it would impact when we merge multi-spec with others specs. Maybe it would be better to wrap the
multi-spec
in ast/spec
and modify theunform*
there, but probably it would need access to the original data.What do you think? Would be ok to add this as a condition in the
encode
function?If you guys could give me direction on the best way to proceed, I could try to submit a patch.
Thanks!
The text was updated successfully, but these errors were encountered: