-
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
clojure.spec.alpha/merge breaks dynamic conforming #90
Comments
Could it be the same thing as I'm seeing? (defn string->clj-time [_ s]
(if (string? s)
(f/parse (:date-time f/formatters) s)
s))
(def doesn't-work-conforming
(spec-tools/type-conforming
{:clj-time string->clj-time}))
(s/def ::named (s/keys :req-un [::name]))
(s/def ::created (spec-tools/spec date-time? {:type :clj-time}))
(s/def ::timestamped (s/keys :req-un [::created]))
(s/def ::broken-thing (s/merge ::timestamped ::named))
(s/def ::working-thing (s/merge ::named ::timestamped))
user> (spec-tools/conform ::broken-thing {:name "foo" :created (str (clj-time.core/now)) } doesn't-work-conforming)
;; => {:name "foo", :created "2018-02-12T21:39:20.084Z"}
user> (spec-tools/conform ::working-thing {:name "foo" :created (str (clj-time.core/now)) } doesn't-work-conforming)
;; => {:name "foo",
:created
#object[org.joda.time.DateTime 0x3491879 "2018-02-12T21:39:28.413Z"]} Yes, it seems to be. I applied the stuff in the pr and problem went away. |
As Alex said, "This is working as designed" but a new JIRA can be created. Please :) I can't see why why it works like it does today. Meanwhile, let's just merge the PR? |
There might be a regression here wrt s/or. I’ll have a look during today and try to come up with a small repro. |
I cannot seem to reproduce the problem I had with |
It's now |
With this spec:
and this input :
in the conformed map, the value of
:kw1
is the string"kw1"
and the value of:kw2
is the keyword:kw2
:The reason is that
clojure.spec.alpha/merge
separately conforms each merged spec, then merges the results, so the unconformed value of:kw1
from the latter result overwrites the conformed value from the former result.The text was updated successfully, but these errors were encountered: