malli 2024-11-14

I'm a bit confused by malli.core/unparse. I'm finding that literal data equal to the result of malli.core/parse cannot be unparsed. Is that intentional?

(def int-or-string [:orn [:int :int] [:str :string]])

(malli.core/parse int-or-string 1) ;; -> [:int 1]

(malli.core/unparse int-or-string [:int 1]) ;=> :malli.core/invalid

(->> 1
     (malli.core/parse int-or-string)
     (malli.core/unparse int-or-string)) ;; => 1

unfortunately that's not a vector, it's a malli tagged value

(malli.core/unparse int-or-string (malli.impl.util/-tagged :int 1))
;; => 1

oh, it's actually not a tagged value, it's a MapEntry!

(class (malli.core/parse int-or-string 1))
;; => clojure.lang.MapEntry

regardless, I think vectors of size 2 should work. could you submit an issue?

👍 1

ah, -tagged just returns a MapEntry