malli

Shantanu Kumar 2025-07-14T15:24:33.950779Z

Hi, is there a way to express :min and :max with number? like it is for :int as in [:map [:num [:int {:min 1 :max 100}]]]?

Matti Uusitalo 2025-07-15T10:05:14.953989Z

The predicate schemas like number? don't allow this. One way to achieve something similar would be e.g.

(malli.core/validate
 [:or
  [:int {:min 1 :max 100}]
  [:double {:min 1 :max 100}]]
 19.0)

Matti Uusitalo 2025-07-15T10:06:39.801759Z

Or with comparator schemas

(malli.core/validate
 [:and [:>= 1] [:<= 100]] 19.0)

Shantanu Kumar 2025-07-15T10:10:56.655009Z

@matti.uusitalo117 thanks, that's reasonable