Skip to content

Commit

Permalink
and
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Aug 8, 2024
1 parent 7c676d6 commit 445f90d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/malli/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@
#(reduce (fn [x parser] (miu/-map-invalid reduced (parser x))) % parsers)))]
^{:type ::schema}
(reify
DistributiveSchema
(-distribute-to-children [this f options']
(-into-schema parent properties (mapv #(f % options) children) options))
Schema
(-validator [_]
(let [validators (-vmap -validator children)] (miu/-every-pred validators)))
Expand Down
22 changes: 22 additions & 0 deletions test/malli/distributive_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,26 @@
[:or
[:map [:y [:= 1]] [:x :int]]
[:map [:y [:= 2]] [:x :int]]]))
(is (= (m/form
(m/deref
[:merge
[:map [:x :int]]
[:and
[:map [:y [:= 1]]]
[:map [:y [:= 2]]]]]
options))
[:and
[:map [:x :int] [:y [:= 1]]]
[:map [:x :int] [:y [:= 2]]]]))
(is (= (m/form
(m/deref
[:merge
[:and
[:map [:y [:= 1]]]
[:map [:y [:= 2]]]]
[:map [:x :int]]]
options))
[:and
[:map [:y [:= 1]] [:x :int]]
[:map [:y [:= 2]] [:x :int]]]))
)

0 comments on commit 445f90d

Please sign in to comment.