This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-08
Channels
- # announcements (2)
- # beginners (75)
- # cider (2)
- # clj-kondo (8)
- # cljs-dev (4)
- # clojure (69)
- # clojure-europe (4)
- # clojure-nl (6)
- # clojure-uk (1)
- # clojurescript (17)
- # clojureverse-ops (1)
- # cursive (7)
- # lsp (7)
- # malli (10)
- # missionary (2)
- # off-topic (16)
- # pathom (4)
- # polylith (5)
- # portkey (1)
- # reitit (4)
- # rewrite-clj (1)
- # shadow-cljs (5)
- # spacemacs (3)
- # specter (3)
- # xtdb (14)
(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)})
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 ...