Skip to content

Commit bc80f3f

Browse files
authored
Merge pull request #1104 from alexander-yakushev/re-find-classcast
Explicitly check for CharSequence in -re-schema
2 parents c25238e + c7bda77 commit bc80f3f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/malli/core.cljc

+4-2
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,8 @@
14671467
(-check-children! :re properties children 1 1)
14681468
(let [children (vec children)
14691469
re (re-pattern child)
1470+
matches? #(and #?(:clj (instance? CharSequence %), :cljs (string? %))
1471+
(re-find re %))
14701472
form (delay (if class? re (-simple-form parent properties children identity options)))
14711473
cache (-create-cache options)]
14721474
^{:type ::schema}
@@ -1475,11 +1477,11 @@
14751477
(-to-ast [this _] (-to-value-ast this))
14761478
Schema
14771479
(-validator [_]
1478-
(-safe-pred #(re-find re %)))
1480+
(-safe-pred matches?))
14791481
(-explainer [this path]
14801482
(fn explain [x in acc]
14811483
(try
1482-
(if-not (re-find re x)
1484+
(if-not (matches? x)
14831485
(conj acc (miu/-error path in this x))
14841486
acc)
14851487
(catch #?(:clj Exception, :cljs js/Error) e

0 commit comments

Comments
 (0)