Skip to content

Commit

Permalink
Merge pull request #1104 from alexander-yakushev/re-find-classcast
Browse files Browse the repository at this point in the history
Explicitly check for CharSequence in -re-schema
  • Loading branch information
ikitommi authored Sep 7, 2024
2 parents c25238e + c7bda77 commit bc80f3f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/malli/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,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}
Expand All @@ -1475,11 +1477,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
Expand Down

0 comments on commit bc80f3f

Please sign in to comment.