Skip to content

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

@dehli

Description

@dehli

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))))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions