From c7bda7742db8b580690555d726bb36aa888c73ba Mon Sep 17 00:00:00 2001 From: Oleksandr Yakushev Date: Fri, 6 Sep 2024 11:44:15 +0300 Subject: [PATCH] Explicitly check for CharSequence in -re-schema --- src/malli/core.cljc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/malli/core.cljc b/src/malli/core.cljc index 05f2fc63c..7b4fd3925 100644 --- a/src/malli/core.cljc +++ b/src/malli/core.cljc @@ -1466,6 +1466,8 @@ (-check-children! :re properties children 1 1) (let [children (vec children) re (re-pattern child) + matches? #(and #?(:clj (instance? CharSequence %), :cljs (string? %)) + (re-find re %)) form (delay (if class? re (-simple-form parent properties children identity options))) cache (-create-cache options)] ^{:type ::schema} @@ -1474,11 +1476,11 @@ (-to-ast [this _] (-to-value-ast this)) Schema (-validator [_] - (-safe-pred #(re-find re %))) + (-safe-pred matches?)) (-explainer [this path] (fn explain [x in acc] (try - (if-not (re-find re x) + (if-not (matches? x) (conj acc (miu/-error path in this x)) acc) (catch #?(:clj Exception, :cljs js/Error) e