Fork me on GitHub

Hi there, i'm using malli 0.6.1 to do some validation in a front-end (cljs)/back-end(clj) application. So I have a .cljc namespace where I do the validations. While this works right with clj, when I use it in cljs I see a warning message

Wrong number of args (3) passed to malli.core/-fail!


fixed in master

👍 2

closed the performance Issue ( - schema creation & transformation is now mostly an order of magnitude faster:

(def schema
   [:x boolean?]
   [:y {:optional true} int?]
   [:z [:map
        [:x boolean?]
        [:y {:optional true} int?]]]])

(def schema (m/schema ?schema))

;; 44µs -> 3.4µs (13x)
(bench (m/schema ?schema))

;; 4.2µs -> 830ns (4.5x)
(bench (mu/assoc schema :w :string))

;; 134µs -> 15µs (9x)
(bench (mu/merge schema schema))

;; 51µs -> 3.9µs (13x)
(bench (mu/closed-schema schema))

😲 2

… and opened a new one, to add first-class support for the (compact) map-syntax: This is really important in for building large schema systems a) via inferring or b) to be run on slow js-runtimes. Initial design (which is already 15x faster 🚀)

(def ?schema
   [:x boolean?]
   [:y {:optional true} int?]
   [:z [:map
        [:x boolean?]
        [:y {:optional true} int?]]]])

(m/form ?schema)
; [:x boolean?]
; [:y {:optional true} int?]
; [:z [:map
;      [:x boolean?]
;      [:y {:optional true} int?]]]]

(m/ast ?schema)
;{:type :map,
; :keys {:x {:order 0
;            :value {:type boolean?}},
;        :y {:order 1, :value {:type int?}
;            :properties {:optional true}},
;        :z {:order 2,
;            :value {:type :map,
;                    :keys {:x {:order 0
;                               :value {:type boolean?}},
;                           :y {:order 1
;                               :value {:type int?}
;                               :properties {:optional true}}}}}}}

(-> ?schema
    (m/schema) ;; 3.7µs
    (m/ast) ;; 1.1µs
    (m/schema) ;; 250ns (15x)
    (= (m/form ?schema)))
; => true

🎉 10

it’s still fully generic, like the mu/to-map-syntax & mu/from-map-syntax , but using a new support protocol, schemas can do whatever they want. The new ast can be used as “I know what I’m doing” kinda way => no parsing & checks needed.