metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.44k stars 204 forks source link

Wrong number of args (5) passed to: clojure.lang.PersistentVector Error #937

Closed garrett-hopper closed 10 months ago

garrett-hopper commented 10 months ago

This appears to be caused by having a :atln with only a single subsequence

(m/validate [:* [:altn [:a [:= :a]]]] [:a])

   Wrong number of args (5) passed to: clojure.lang.PersistentVector

                  AFn.java:  429  clojure.lang.AFn/throwArity
                  AFn.java:   48  clojure.lang.AFn/invoke
                regex.cljc:  286  malli.impl.regex$_STAR__validator$_STAR_p__37514/invoke
                regex.cljc:  152  malli.impl.regex$cat_validator$fn__37390$fn__37391/invoke
                regex.cljc:  556  malli.impl.regex$validator$fn__37692/invoke
                 core.cljc: 2124  malli.core$validate/invokeStatic
                 core.cljc: 2118  malli.core$validate/invoke
                 core.cljc: 2122  malli.core$validate/invokeStatic
                 core.cljc: 2118  malli.core$validate/invoke
;; Fails with (Wrong number of args (5) passed to: clojure.lang.PersistentVector)
(m/explain ;; (or m/validate)
 [:* [:altn
      [:a [:= :a]]]]
 [:a])

;; Works
(m/parse
 [:* [:altn
      [:a [:= :a]]]]
 [:a])

;; Works
(m/parse
 [:* [:altn
      [:a [:= :a]]
      [:b [:= :b]]]]
 [:a :b])

;; Works
(m/validate
 [:* [:altn
      [:a [:= :a]]
      [:b [:= :b]]]]
 [:a :b])

;; Works
(m/explain
 [:* [:altn
      [:a [:= :a]]
      [:b [:= :b]]]]
 [:a :c])