From 946dac3c9f1327371997a1d8351a14836f4824fa Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 6 Nov 2024 09:15:06 +0100 Subject: [PATCH] :bug: Fix NPE on number schemas Mainly, without this fix, happens the following: user=> (sm/validate [::sm/int {:min 0}] nil) Execution error (NullPointerException) at app.common.schema/fn$fn (schema.cljc:692). Cannot invoke "Object.getClass()" because "x" is null And it should return `false` without an exception. --- common/src/app/common/schema.cljc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index 25e802f8b4..54d8e1910c 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -681,8 +681,8 @@ (let [pred int? pred (if (some? min) (fn [v] - (and (>= v min) - (pred v))) + (and (pred v) + (>= v min))) pred) pred (if (some? max) (fn [v] @@ -719,8 +719,8 @@ (let [pred double? pred (if (some? min) (fn [v] - (and (>= v min) - (pred v))) + (and (pred v) + (>= v min))) pred) pred (if (some? max) (fn [v] @@ -749,8 +749,8 @@ (let [pred number? pred (if (some? min) (fn [v] - (and (>= v min) - (pred v))) + (and (pred v) + (>= v min))) pred) pred (if (some? max) (fn [v]