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

select-spec removing keys when using s/or #264

Open
dehli opened this issue Nov 13, 2021 · 0 comments
Open

select-spec removing keys when using s/or #264

dehli opened this issue Nov 13, 2021 · 0 comments

Comments

@dehli
Copy link
Contributor

dehli commented Nov 13, 2021

Hi, as I was using this library I ran into what I think is a small bug w/ select-spec.

The bug seems to stem from using s/or. The following test highlights the invalid code (you'll see it referenced in a linked commit).

(s/def ::str-264 string?)
(s/def ::kw-264 keyword?)
(s/def ::map-264 (s/or :str-map (s/keys :req [::str-264])
                       :kw-map (s/keys :req [::kw-264])))

(deftest issue-264
  (doseq [check [{::kw-264 :foo}
                 {::str-264 "bar"}]]

    (testing "specs are valid before calling st/select-spec"
      (is (s/valid? ::map-264 check)))

    (testing "specs stay valid after calling st/select-spec"
      ;; This line fails b/c select-spec returns {}
      (is (s/valid? ::map-264 (st/select-spec ::map-264 check))))))
dehli added a commit to dehli/spec-tools that referenced this issue Nov 13, 2021
dehli added a commit to dehli/spec-tools that referenced this issue Nov 13, 2021
dehli added a commit to dehli/spec-tools that referenced this issue Nov 13, 2021
dehli added a commit to dehli/spec-tools that referenced this issue Nov 13, 2021
dehli added a commit to dehli/spec-tools that referenced this issue Nov 13, 2021
dehli added a commit to dehli/spec-tools that referenced this issue Nov 13, 2021
@dehli dehli changed the title select-spec removing keys when using ds/or select-spec removing keys when using s/or Nov 13, 2021
dehli added a commit to dehli/spec-tools that referenced this issue Nov 13, 2021
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