This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

## 2022-02-24

## Channels

- # announcements (5)
- # aws (5)
- # aws-lambda (6)
- # babashka (6)
- # beginners (48)
- # calva (54)
- # clj-commons (12)
- # clj-kondo (39)
- # cljfx (3)
- # cljs-dev (11)
- # clojure (91)
- # clojure-europe (25)
- # clojure-uk (3)
- # clojurescript (16)
- # cursive (2)
- # data-oriented-programming (6)
- # datomic (8)
- # emacs (10)
- # events (3)
- # fulcro (2)
- # functionalprogramming (2)
- # graalvm (4)
- # graphql (2)
- # helix (1)
- # honeysql (4)
- # jobs (1)
- # malli (4)
- # nextjournal (21)
- # off-topic (5)
- # other-languages (4)
- # overtone (3)
- # reitit (17)
- # releases (2)
- # rewrite-clj (6)
- # ring (6)
- # shadow-cljs (37)

@lambder above issue fixed on the latest release - see https://github.com/henryw374/time-literals readme for details. tl;dr it was basically a workaround for a problem with Clojurescript that has taken some time to get fixed - see https://clojure.atlassian.net/browse/CLJS-3294

@henryw374 Thank you !

@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]}]
(cond
(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
(malli/-simple-schema
(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]]}})))
```