Skip to content

Commit

Permalink
Use private not-found object as .valAt argument
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Aug 2, 2024
1 parent 9b469de commit dcfcd0e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/malli/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,12 @@
(if-let [entry (find m k)]
(assoc m k (t (val entry)))
m)) x ts))
:clj (apply -comp (map (fn child-transformer [[k t]]
(fn [^Associative x]
(let [val (.valAt x k ::not-found)]
(if (identical? val ::not-found)
x (.assoc x k (t val)))))) (rseq ts)))
:clj (let [not-found (Object.)]
(apply -comp (map (fn child-transformer [[k t]]
(fn [^Associative x]
(let [val (.valAt x k not-found)]
(if (identical? val not-found)
x (.assoc x k (t val)))))) (rseq ts))))
:cljs (fn [x] (reduce (fn child-transformer [m [k t]]
(if-let [entry (find m k)]
(assoc m k (t (val entry)))
Expand Down Expand Up @@ -1038,11 +1039,12 @@
(let [valid? (-validator value)
default (boolean optional)]
#?(:bb (fn [m] (if-let [map-entry (find m key)] (valid? (val map-entry)) default))
:clj (fn [^Associative m]
(let [val (.valAt m key ::not-found)]
(if (identical? val ::not-found)
default
(valid? val))))
:clj (let [not-found (Object.)]
(fn [^Associative m]
(let [val (.valAt m key not-found)]
(if (identical? val not-found)
default
(valid? val)))))
:cljs (fn [m] (if-let [map-entry (find m key)] (valid? (val map-entry)) default)))))
@explicit-children)
default-validator
Expand Down

0 comments on commit dcfcd0e

Please sign in to comment.