Fork me on GitHub

@lambder above issue fixed on the latest release - see readme for details. tl;dr it was basically a workaround for a problem with Clojurescript that has taken some time to get fixed - see


this worked like a charm 😄


@ikitommi I wrote a version of -min-max-pred that can deal with nil being passed to it as I could not figure out an f that could transform nil into a number that would make sense min and max to apply to. If you think you have use for it anywhere in Malli, here it is:

(defn -nilable-min-max-pred [f nilable]
  (fn [{:keys [min max]}]
      (not (or min max))    nil
      (and  min max f nilable) (fn [x] (if (nil? x) true (let [size (f x)] (<= min size max))))
      (and  min max f)         (fn [x] (let [size (f x)] (<= min size max)))
      (and min max nilable)    (fn [x] (if (nil? x) true (<= min x max)))
      (and min max)            (fn [x] (<= min x max))
      (and min f nilable)      (fn [x] (if (nil? x) true (<= min (f x))))
      (and min f)              (fn [x] (<= min (f x)))
      (and min nilable)        (fn [x] (if (nil? x) true (<= min x)))
      min                      (fn [x] (<= min x))
      (and max f nilable)      (fn [x] (if (nil? x) true (<= (f x) max)))
      (and max f)              (fn [x] (<= (f x) max))
      (and max nilable)        (fn [x] (if (nil? x) true (<= x max)))
      max                      (fn [x] (<= x max)))))
And its use in my code is just:
(register! :html/nilable-int
   (fn [opts _]
     {:type            :html/nilable-int
      :pred            (some-fn int? nil?)
      :property-pred   (su/-nilable-min-max-pred nil true)
      :description     "An int or nil. Empty string is transformed to nil."
      :type-properties {:decode/string (fn [x] (when-not (string/blank? x)
                                                 (mtransform/-string->long x)))
                        :gen/schema [:maybe [:int opts]]}})))