Fork me on GitHub
#malli
<
2021-08-08
>
ikitommi17:08:24

it’s out! (actually 0.6.1 as there was a missing dependency)

emccue17:08:53

Getting what is perhaps a simple error, but

emccue17:08:09

(ns dev.mccue.domain.user
  (:require
    [malli.instrument :as instrument]))

;; ----------------------------------------------------------------------------
(def User [:and [:map
                 [:user/email :string]
                 [:user/password-hash :string]]
           [:fn {:error/message "should have user metadata"}
            (fn [o] (= (type o) ::user))]])

;; ----------------------------------------------------------------------------
(defn create
  {:malli/schema [:=>
                  [:cat [:map
                         [:email :string]
                         [:password-hash :string]]]
                  User]}
  [{:keys [email password-hash]}]
  ^{:type ::user}
  {:user/email         email
   :user/password-hash password-hash})

;; ----------------------------------------------------------------------------
(def ^{:malli/schema [:=> [:cat User] :string]}
  email
  :user/email)

;; ----------------------------------------------------------------------------
(def
  ^{:malli/schema [:=> [:cat User] :string]}
  password-hash
  :user/password-hash)

;; ----------------------------------------------------------------------------
(instrument/collect!)

;; ....
(malli.dev/start! {:report (malli.dev.pretty/reporter)})

Tuomas05:08:44

I could reduce it down to be about malli.dev.pretty/reporter and :fn but couldn't figure out the reason for overflow.

(defn identity-42
  {:malli/schema [:=> [:cat [:fn (fn [n] (= 42 n))]] :int]}
  [a] a)

(instrument/collect!)
(malli.dev/start! {:report (malli.dev.pretty/reporter)})
(identity-42 41) ; Execution error (StackOverflowError) at fipp.ednize/override? (ednize.clj:12)

(malli.dev/stop!)
(malli.dev/start!)
(identity-42 41) ; :malli.core/invalid-input {:input [:cat [:fn #funct ...

emccue17:08:24

this is what i load in (requiring malli dev and malli pretty in repl)

emccue17:08:31

(password-hash {})
Execution error (StackOverflowError) at fipp.ednize/override? (ednize.clj:12).
null

emccue17:08:24

and this is what happens when i try invalid input

emccue17:08:34

(password-hash (create {:email "A" :password-hash "a"}))
=> "a"

emccue17:08:39

valid input works fine though

emccue17:08:51

just changed to [metosin/malli "0.6.1"]