malli

erre lin 2025-08-25T12:50:07.914639Z

I have a spec like this

(def BigInt
  (m/-simple-schema
    {:type :bigint
     :pred  #?(:cljs (and (bigint? %) (<= (js/BigInt 0) %))
               :clj (and (integer? %) (<= 0 %)))
     :type-properties
     {:error/message "should be positive js/BigInt or a long"
      :gen/gen #?(:cljs js/BigInt
                  :clj (gen/large-integer* {:min 0}))}}))
It works in ClojureScript, but always fails in Clojure. But I'm confused as to the below
;; in clojure repl
(and (integer? 0) (<= 0 0)) ;; => true
(m/validate BigInt 0) ;; => false
How should I define my schema properly so that it checks a large, non-negative integer? nat-int? does not work with bigint in Clojure. Thanks