Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Aug 27, 2024
1 parent 0d30c16 commit 5747e9a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/malli/error.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@
(reduce (fn [acc error] (cond-> acc (accept error) (-replace-in value (:in error) (wrap error) mask))) acc errors)))

(defn -masked [mask x y]
(cond (and (map? x) (or (nil? y) (map? y))) (reduce-kv (fn [acc k v] (let [e (find y k)] (assoc acc k (if e (-masked mask v (val e)) mask)))) y x)
(set? x) (cond-> y (not= (count x) (count y)) (conj mask))
(sequential? x) (-fill y (count x) mask)
:else y))
(let [nested (and (map? x) (or (map? y) (nil? y)))]
(cond nested (reduce-kv (fn [acc k v] (let [e (find y k)] (assoc acc k (if e (-masked mask v (val e)) mask)))) y x)
(set? x) (cond-> y (not= (count x) (count y)) (conj mask))
(sequential? x) (-fill y (count x) mask)
:else y)))

;;
;; spell checking (kudos to https://github.com/bhauman/spell-spec)
Expand Down

0 comments on commit 5747e9a

Please sign in to comment.