Skip to content

get doesn't support or syntax in clojure.spec.alpha/keys #9

Description

@PavlosMelissinos

Repro:

(s/def :test/foo number?)
(s/def :test/bar string?)
(s/def :test/baz (s/and number? pos?))

(s/def :test/spec
  (s/keys :req-un [:test/foo]
          :opt-un [:test/baz]))

(s/def :test/spec-with-or
  (s/keys :req-un [(or :test/foo :test/bar)]
          :opt-un [:test/baz]))

;; this works as expected
(lens/get {:foo -1 :baz 1} :test/spec :foo)
;;=> -1

;; but this doesn't work
(lens/get {:foo -1 :baz 1} :test/spec-with-or :foo)
  ;; Unhandled java.lang.ClassCastException
  ;;  class clojure.lang.PersistentList cannot be cast to class clojure.lang.Named
  ;;  (clojure.lang.PersistentList and clojure.lang.Named are in unnamed module of
  ;;  loader 'app')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions